Skip to content

Conversation

@tomatosalat0
Copy link
Contributor

The test ShouldUnwrapPromiseWithCustomTimeout did randomly fail, so I tried to rewrite it to make it reliable.

The test randomly failed with

Jint.Tests.Runtime.AsyncTests.ShouldUnwrapPromiseWithCustomTimeout [FAIL]

Error: Jint.Runtime.PromiseRejectedException : Promise was rejected with value Timeout of 00:00:00.2000000 reached

which can happen if the system is under high load and the Task state machine didn't get CPU time to process the completed Task.Delay within AsyncTestClass.ReturnDelayedTaskAsync().


The rewrite attempts to fix that by basically always rejecting the unwrapping with a timeout of 1ms. This ensures that the provided custom timeout is used. The timeout should always happen, independent of when the async state machine got time to process the result.

The test above (ShouldReturnedTaskConvertedToPromiseInJS) still checks the happy path for proper unwrapping.

@lahma lahma force-pushed the fix/rewrite-flaky-test branch from 9fcf29c to fe00c8a Compare November 9, 2025 15:41
Copy link
Collaborator

@lahma lahma left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, this has been annoying! 👍🏻

@lahma lahma enabled auto-merge (squash) November 9, 2025 15:42
@tomatosalat0
Copy link
Contributor Author

Ok, a failing ModuleTests.ShouldSupportConstraints a new one for me 😆 - runs like a charm in isolation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants