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

Revert "docs(client-aborted): remove deprecated function (#4898)" #4901

Merged
merged 1 commit into from
Jul 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/Guides/Detecting-When-Clients-Abort.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ const app = Fastify({

app.addHook('onRequest', async (request, reply) => {
request.raw.on('close', () => {
if (request.raw.destroyed) {
if (request.raw.aborted) {
app.log.info('request closed')
}
})
Expand Down Expand Up @@ -85,7 +85,7 @@ functionality:
of `{ ok: true }`.
- An onRequest hook that triggers when every request is received.
- Logic that triggers in the hook when the request is closed.
- Logging that occurs when the closed request property `destroyed` is true.
- Logging that occurs when the closed request property `aborted` is true.

In the request close event, you should examine the diff between a successful
request and one aborted by the client to determine the best property for your
Expand All @@ -97,7 +97,7 @@ You can also perform this logic outside of a hook, directly in a specific route.
```js
app.get('/', async (request, reply) => {
request.raw.on('close', () => {
if (request.raw.destroyed) {
if (request.raw.aborted) {
app.log.info('request closed')
}
})
Expand All @@ -112,7 +112,7 @@ aborted and perform alternative actions.
```js
app.get('/', async (request, reply) => {
await sleep(3000)
if (request.raw.destroyed) {
if (request.raw.aborted) {
// do something here
}
await sleep(3000)
Expand Down