js-temporal / temporal-polyfill

Polyfill for Temporal (under construction)
ISC License
530 stars 28 forks source link

[Test262] Temporal Now/instant/return-value-value seems flaky due to SystemUTCEpochNanoSeconds impl #161

Closed 12wrigja closed 2 years ago

12wrigja commented 2 years ago

The content of that 262 test:

var nowBefore = Date.now();
var seconds = Number(Temporal.Now.instant().epochNanoseconds / 1000000n);
var nowAfter = Date.now();
assert(seconds >= nowBefore, 'The result of evaluating (seconds >= nowBefore) is expected to be true');
assert(seconds <= nowAfter, 'The result of evaluating (seconds <= nowAfter) is expected to be true');

In some cases, the value of nowAfter is before seconds and the second assertion is failing.

As far as I can tell, this is likely due to the code for SystemUTCEpochNanoSeconds that attempts to ensure that the returned value here is always incrementing.

I don't know of a straightforward way to repro this using the OSS testing setup, as it only appears to be a problem infrequently and only when the code is run very quickly (e.g. putting the code in the debugger causes enough time to pass that the tests pass).

12wrigja commented 2 years ago

@pipobscure any insight here? @ptomato recommended I ask you about this.

12wrigja commented 2 years ago

After some more investigation, this might be due to some weird side-effects going on with an experimental test environment I'm trying out to make running the Test262 tests run faster.