Unable to properly monitor the close event of page request
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 11.2k
- Forks
- 899
- Avg merge
- 2d 24m
- Merged PRs (30d)
- 40
Description
Describe the feature
As I said here #23569, when I try to listen for the close event, it doesn't fire the close event correctly when I interrupt the page request.
But when the page request ends normally, it can trigger the close event after triggering the end event.
this is a reproduction.
https://codesandbox.io/p/sandbox/stoic-sanderson-y6wjgg
I tried to add a global close event here, which can be triggered normally including interrupt requests.
https://github.com/unjs/nitro/blob/ae253596a847f764e275f7e0450ffdfcdcd8957e/src/runtime/entries/node-server.ts#L15
But there is a problem when I get the req through nuxtApp.ssrContext.event.node
Additional information
- Would you be willing to help implement this feature?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked CodeSandbox reproduction and src/runtime/entries/node-server.ts, especially the global close-event handling described there. Trace how req is exposed through nuxtApp.ssrContext.event.node and compare interrupted requests with normally completed ones. Done means the close event is observable for interrupted page requests without breaking the existing end-then-close behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- node.js, nuxt, typescript
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100