nodejs / node

Node.js JavaScript runtime ✨🐢🚀✨

Home Page:https://nodejs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`test-buffer-tostring-rangeerror` is flaky (timeout)

aduh95 opened this issue · comments

Test

test-buffer-tostring-rangeerror

Platform

Linux x64

Console output

not ok 1244 parallel/test-buffer-tostring-rangeerror
  ---
  duration_ms: 120073.76400
  severity: fail
  exitcode: -15
  stack: |-
    timeout
    (node:2934155) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead.
    (Use `node --trace-deprecation ...` to show where the warning was created)
  ...

Build links

Additional information

No response

I'm able to reproduce locally: running the test 100'000 times, I got 6 timeouts. If I add a console.log("pass") at the end of the file, it gets printed even when the test times out. Adding process.exit(); does not help.

I also investigated this a bit earlier. I was able to reproduce it quite consistently with just a 1000 runs and reduced it to this:

'use strict';
require('../common');

const assert = require('assert');
const { constants: { MAX_STRING_LENGTH } } = require('buffer');

const len = MAX_STRING_LENGTH + 1;
const message = {
  code: 'ERR_STRING_TOO_LONG',
  name: 'Error',
};
assert.throws(() => Buffer(len).toString('utf8'), message);
assert.throws(() => Buffer(len).toString('utf8'), message);

Removing either the second buffer.toString call, the ../common import, adding a console.log('pass') at the end or using a debug build will make it not reproduce anymore. 🙃 🤔

Could we try to add --no-warnings CLI flag and see if that would have any effect? EDIT: nope, I tried with both --no-warnings and --no-deprecation, and I was still getting timeouts