Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Breaks on node 11 #257

Closed
hueniverse opened this issue Nov 11, 2018 · 4 comments · Fixed by #259
Closed

Breaks on node 11 #257

hueniverse opened this issue Nov 11, 2018 · 4 comments · Fixed by #259
Labels
bug Bug or defect dependency Update module dependency

Comments

@hueniverse
Copy link
Contributor

I removed node 11 from travis until this is resolved.

@cjihrig can you also take a look?

@hueniverse hueniverse added bug Bug or defect dependency Update module dependency labels Nov 11, 2018
@cjihrig
Copy link
Contributor

cjihrig commented Nov 11, 2018

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.

'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:

'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
Copy link
Contributor

cjihrig commented Nov 12, 2018

Opened nodejs/node#24320.

@cjihrig
Copy link
Contributor

cjihrig commented Nov 15, 2018

@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
Copy link

lock bot commented Jan 9, 2020

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.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 9, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Bug or defect dependency Update module dependency
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants