Skip to content

Commit

Permalink
fix 'uWS.HttpResponse writes must be made from within a corked callba…
Browse files Browse the repository at this point in the history
…ck.'
  • Loading branch information
endel committed Nov 6, 2024
1 parent 7b53171 commit ef160e5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "uwebsockets-express",
"version": "1.3.12",
"version": "1.3.13",
"description": "Express API compatibility layer for uWebSockets.js",
"main": "./build/index.js",
"module": "./build/index.mjs",
Expand Down
6 changes: 3 additions & 3 deletions src/ServerResponse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@ export class ServerResponse extends EventEmitter /* implements http.ServerRespon
// write status + headers
this.writeHead(this.statusCode || this.statusCode, this._headers);

// dequeue writes
this._writes.forEach((chunk) => this.res.write(chunk));

// write response
this.res.cork(() => {
// dequeue writes
this._writes.forEach((chunk) => this.res.write(chunk));

this.res.end(body);
});
}
Expand Down

1 comment on commit ef160e5

@angleKH
Copy link
Contributor

@angleKH angleKH commented on ef160e5 Nov 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great change! This fixed an issue I had using ViteDevServer's middleware

Please sign in to comment.