hapijs / nes

WebSocket adapter plugin for hapi routes
Other
502 stars 87 forks source link

Breaks on node 11 #257

Closed hueniverse closed 5 years ago

hueniverse commented 5 years ago

I removed node 11 from travis until this is resolved.

@cjihrig can you also take a look?

cjihrig commented 5 years ago

This appears to be a timers bug in Node core. On my machine (macOS), Node 11.1.0 and latest Node master branch (Node 10 is not impacted), the following command just hangs:

$ node node_modules/.bin/lab -i 113

The setTimeout() inside this call to Hoek.wait() never calls its callback.

I've been able to reproduce this without lab and hoek, but haven't put together a reproduction without hapi+nes.

```js 'use strict'; const Hapi = require('hapi'); const Nes = require('./'); async function main() { const server = Hapi.server(); await server.register({ plugin: Nes, options: { auth: false, heartbeat: { interval: 50, timeout: 45 } } }); server.route({ method: 'GET', path: '/', handler: async () => { await wait(110); return 'hello'; } }); await server.start(); const client = new Nes.Client('http://localhost:' + server.info.port); await client.connect(); await client.request('/'); client.disconnect(); await server.stop(); } setTimeout(() => {}, 1000); main(); function wait(timeout) { return new Promise((resolve) => { setTimeout(resolve, timeout); }); }; ```

EDIT: Potential reproduction using only Node core:

```js 'use strict'; let client = null; function serverBeat() { setTimeout(() => {}, 45); setTimeout(serverBeat, 50); clientBeat(); } function clientBeat() { clearTimeout(client); client = setTimeout(clientBeat, 95); } setTimeout(() => {}, 10000); setTimeout(serverBeat, 50); setTimeout(() => {}, 120000); clientBeat(); setTimeout(() => { console.log('finished!'); process.exit(); }, 110); ```
cjihrig commented 5 years ago

Opened https://github.com/nodejs/node/issues/24320.

cjihrig commented 5 years ago

@hueniverse this should be fixed in Node 11.2.0, which was just released. The nes test suite passes for me locally on 11.2.0.

lock[bot] commented 4 years ago

This thread has been automatically locked due to inactivity. Please open a new issue for related bugs or questions following the new issue template instructions.