Skip to content

Commit

Permalink
fixed: Sockets hanging (closes #7097) (#2976)
Browse files Browse the repository at this point in the history
* fixed: Sockets hanging

* added past solution

* refactor

* bump version
  • Loading branch information
PavelMor25 authored Nov 16, 2023
1 parent 2cb2f3c commit 0113d2d
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "testcafe-hammerhead",
"description": "A powerful web-proxy used as a core for the TestCafe testing framework (https://github.com/DevExpress/testcafe).",
"version": "31.6.3",
"version": "31.6.4",
"homepage": "https://github.com/DevExpress/testcafe-hammerhead",
"bugs": {
"url": "https://github.com/DevExpress/testcafe-hammerhead/issues"
Expand Down
9 changes: 9 additions & 0 deletions src/request-pipeline/context/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,15 @@ export default class RequestPipelineContext extends BaseRequestPipelineContext {
this.goToNextStage = false;
}

closeConnectionOnError (): void {
this.req.destroy();

// 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.
if (this.req.socket && !this.req.socket.destroyed)
this.req.socket.destroy();

}

toProxyUrl (url: string, isCrossDomain: boolean, resourceType: string, charset?: string, reqOrigin?: string, credentials?: urlUtils.Credentials): string {
const proxyHostname = this.serverInfo.hostname;
const proxyProtocol = this.serverInfo.protocol;
Expand Down
2 changes: 1 addition & 1 deletion src/request-pipeline/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export function error (ctx: RequestPipelineContext, err: string) {
if (ctx.isPage && !ctx.isIframe)
ctx.session.handlePageError(ctx, err);
else if (ctx.isAjax)
ctx.req.destroy();
ctx.closeConnectionOnError();
else
ctx.closeWithError(500, err.toString());
}
Expand Down

0 comments on commit 0113d2d

Please sign in to comment.