Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] The Serve-Send-Event request cannot receive a close event. #50804

Closed
1 task done
StringKe opened this issue Jun 5, 2023 · 7 comments
Closed
1 task done

[BUG] The Serve-Send-Event request cannot receive a close event. #50804

StringKe opened this issue Jun 5, 2023 · 7 comments
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js.

Comments

@StringKe
Copy link

StringKe commented Jun 5, 2023

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
      Platform: darwin
      Arch: arm64
      Version: Darwin Kernel Version 22.5.0: Mon Apr 24 20:52:24 PDT 2023; root:xnu-8796.121.2~5/RELEASE_ARM64_T6000
    Binaries:
      Node: 18.16.0
      npm: 9.5.1
      Yarn: 1.22.19
      pnpm: 8.6.0
    Relevant packages:
      next: 13.4.4
      eslint-config-next: 13.4.4
      react: 18.2.0
      react-dom: 18.2.0
      typescript: 5.1.3

Which area(s) of Next.js are affected? (leave empty if unsure)

Middleware / Edge (API routes, runtime)

Link to the code that reproduces this issue or a replay of the bug

https://stackblitz.com/edit/stackblitz-starters-n5uvup?file=pages%2Findex.js

To Reproduce

  1. open the recurrence connection (I did not find the page function of CodeSandbox, I used StackBlitz)
  2. Open the browser console
  3. Click the button and wait a while
  4. Click the button again.

Describe the Bug

Create an SSE (Server-Sent-Event) request using an API Endpoint that does not receive a disconnect event properly when the client disconnects.

Expected Behavior

API Request is able to accept disconnected events, as the inability to accept events causes the timer to run forever and add a new one each time it runs.

Which browser are you using? (if relevant)

Microsoft Edge 113.0.1774.57

How are you deploying your application? (if relevant)

none

note 2023-6-6

I tried to write an api with the same functionality using express and I can receive the close event.

https://github.com/StringKe/node-sse-example

link1: #48682

@StringKe StringKe added the bug Issue was opened via the bug report template. label Jun 5, 2023
@github-actions github-actions bot added the Runtime Related to Node.js or Edge Runtime with Next.js. label Jun 5, 2023
@helmturner
Copy link

Is this expected behavior? It seems to be mentioned in the fastify docs https://www.fastify.io/docs/latest/Guides/Detecting-When-Clients-Abort/

@timcole
Copy link

timcole commented Jun 8, 2023

Heyo, I tested this out and noticed two things.

  1. I tried it locally and same issue, however if I downgrade next to v12.3.4 it works as expected, and 3 of the 4 on close events fire. The issue seems to be next v13 related.
  2. Stackblitz's proxy seems to keep the connection alive so it never closes no matter which version I use.

@TCatshoek
Copy link

I also tested it locally, and it seems to work on [email protected], but not on latest. It seems like any version higher than 13.2.4 causes issues (13.3.0 does not work properly)

@StringKe
Copy link
Author

StringKe commented Jun 11, 2023

I tested the version and found that this issue first appeared in 13.2.5-canary.27.

13.2.5-canary.26 is work

I checked all commit records in 13.2.5-canary.26 through 13.2.5-canary.27, and this commit may be the cause.

fdacca8

https://github.com/vercel/next.js/commits/canary?before=819453e3a6cc4f35be4d988d4119579c8e46488e+35

StringKe referenced this issue Jun 11, 2023
This updates to have a separate routing process and separate rendering
processes for `pages` and `app` so that we can properly isolate the two
since they rely on different react versions.

Besides allowing the above mentioned isolation this also helps us
control recovering from process crashes easier as pieces are more
isolated from one another e.g. an infinite loop during rendering will no
longer block the compiler and can be stopped/restarted as needed.

In follow-up PRs we will continue to separate out the routing logic from
the rendering logic so that each process only loads what is relevant to
it helping simplify the flow for requests regardless of type.

---------

Co-authored-by: Shu Ding <[email protected]>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
@StringKe StringKe changed the title The Serve-Send-Event request cannot receive a close event. [BUG] The Serve-Send-Event request cannot receive a close event. Jun 16, 2023
@StringKe
Copy link
Author

[email protected] The presence of this problem remains.

v13.4.8-canary.5 The problem was not detected

@jridgewell
Copy link
Contributor

Fixed by #51727

@github-actions
Copy link
Contributor

This closed issue has been automatically locked because it had no new activity for a month. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 29, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue was opened via the bug report template. locked Runtime Related to Node.js or Edge Runtime with Next.js.
Projects
None yet
Development

No branches or pull requests

5 participants