uNetworking / uWebSockets.js

μWebSockets for Node.js back-ends :metal:
Apache License 2.0
7.76k stars 563 forks source link

v20.22.0 release provide wrong version via package.json #887

Closed webcarrot closed 1 year ago

webcarrot commented 1 year ago

package.json provided by v20.22.0 looks like:

{
  "name": "uWebSockets.js",
  "version": "20.21.0",
  "main": "uws.js",
  "types": "./index.d.ts",
  "exports": {
    "import": "./ESM_wrapper.mjs",
    "require": "./uws.js",
    "types": "./index.d.ts"
  }
}
webcarrot commented 1 year ago

I also noticed some segmentation fault errors during unit test runs.

They are quite strange - I will try to debug them.

Example code:

import { App } from 'uWebSockets.js';

const server = App();

const PORT = 8080;

server.get('/*', (res, req) => {
    console.log('Req start');
    res.onAborted(() => {
        console.log('Aborted');
    });
    setImmediate(() => {
        res.cork(() => {
            res.writeStatus('200 OK');
            res.writeHeader('content-type', 'application/octet-stream');
            res.end(Buffer.allocUnsafe(16388));
            console.log('Req end');
        });
    });
});

server.listen(PORT, () => {
    console.log(`Start on: ${PORT}`);
});

console.log(`Please open http://127.0.0.1:${PORT}/`);

Output:

Start on: 8080
Please open http://127.0.0.1:8080/
Req start
Req end
[1]    74109 segmentation fault  node test.mjs
webcarrot commented 1 year ago

Looks like from now we should just wrap everything with res.cork? 🙄 :

server.get('/*', (res, req) => {
    res.cork(() => {
        console.log('Req start');
        res.onAborted(() => {
            console.log('Aborted');
        });
        setImmediate(() => {
            res.writeStatus('200 OK');
            res.writeHeader('content-type', 'application/octet-stream');
            res.end(Buffer.allocUnsafe(16388));
            console.log('Req end');
        });
    });
});
uNetworkingAB commented 1 year ago

What Node.js version has the problems? Nothing should have changed for older Node.js versions. Can you confirm that only Node.js 20 has the problems?

webcarrot commented 1 year ago

Node v18.16.0

Also in v16.15.0 and v20.0.0

uNetworkingAB commented 1 year ago

Is this crash new for v20.22 or did it exit in prior versions?

uNetworkingAB commented 1 year ago

Ah okay I can reproduce the crash from v20.21.0 and forwards but not before. So something broke recently

uNetworkingAB commented 1 year ago

Should be fixed in next release, waiting for CI

uNetworkingAB commented 1 year ago

Confirmed fixed, thanks for reporting. Will release any time now