mirror of
https://github.com/gristlabs/grist-core.git
synced 2026-03-02 04:09:24 +00:00
(core) tweak handler for aborted connections to work on modern node
Summary:
It became hard to detect aborted connections in node 16.
In node 14, req.on('close', ...) did the job. Thid diff adds a
work-around, until a better way is discovered or added.
Aborting a req will typically lead to 'close' being called
on the response, without writableFinished being set.
- https://github.com/nodejs/node/issues/38924
- https://github.com/nodejs/node/issues/40775
Test Plan:
existing DocApiForwarder test passes; manually
checking on various node versions.
Reviewers: JakubSerafin
Reviewed By: JakubSerafin
Differential Revision: https://phab.getgrist.com/D3923
This commit is contained in:
@@ -10,6 +10,7 @@ import { IDocWorkerMap } from "app/server/lib/DocWorkerMap";
|
||||
import { expressWrap } from "app/server/lib/expressWrap";
|
||||
import { GristServer } from "app/server/lib/GristServer";
|
||||
import { getAssignmentId } from "app/server/lib/idUtils";
|
||||
import { addAbortHandler } from "app/server/lib/requestUtils";
|
||||
|
||||
/**
|
||||
* Forwards all /api/docs/:docId/tables requests to the doc worker handling the :docId document. Makes
|
||||
@@ -101,7 +102,7 @@ export class DocApiForwarder {
|
||||
|
||||
// If the original request is aborted, abort the forwarded request too. (Currently this only
|
||||
// affects some export/download requests which can abort long-running work.)
|
||||
req.on('close', () => controller.abort());
|
||||
addAbortHandler(req, res, () => controller.abort());
|
||||
|
||||
const options: RequestInit = {
|
||||
method: req.method,
|
||||
|
||||
Reference in New Issue
Block a user