Skip to content

Commit 0113d2d

Browse files
authored
fixed: Sockets hanging (closes #7097) (#2976)
* fixed: Sockets hanging * added past solution * refactor * bump version
1 parent 2cb2f3c commit 0113d2d

4 files changed

Lines changed: 13 additions & 4 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "testcafe-hammerhead",
33
"description": "A powerful web-proxy used as a core for the TestCafe testing framework (https://github.com/DevExpress/testcafe).",
4-
"version": "31.6.3",
4+
"version": "31.6.4",
55
"homepage": "https://github.com/DevExpress/testcafe-hammerhead",
66
"bugs": {
77
"url": "https://github.com/DevExpress/testcafe-hammerhead/issues"

src/request-pipeline/context/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,15 @@ export default class RequestPipelineContext extends BaseRequestPipelineContext {
426426
this.goToNextStage = false;
427427
}
428428

429+
closeConnectionOnError (): void {
430+
this.req.destroy();
431+
432+
// NOTE: For Node versions greater than 15.4, we check the socket. If req.destroy didn't destroy it, we call the corresponding method of the socket.
433+
if (this.req.socket && !this.req.socket.destroyed)
434+
this.req.socket.destroy();
435+
436+
}
437+
429438
toProxyUrl (url: string, isCrossDomain: boolean, resourceType: string, charset?: string, reqOrigin?: string, credentials?: urlUtils.Credentials): string {
430439
const proxyHostname = this.serverInfo.hostname;
431440
const proxyProtocol = this.serverInfo.protocol;

src/request-pipeline/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ export function error (ctx: RequestPipelineContext, err: string) {
9090
if (ctx.isPage && !ctx.isIframe)
9191
ctx.session.handlePageError(ctx, err);
9292
else if (ctx.isAjax)
93-
ctx.req.destroy();
93+
ctx.closeConnectionOnError();
9494
else
9595
ctx.closeWithError(500, err.toString());
9696
}

0 commit comments

Comments
 (0)