Commit c8bfe2f
authored
test(flaky): fix unresolved promise causing linux failures (#6088)
## Problem
#6043
To reproduce, add a 5 second delay to the `after` hook at the top level.
One way to do this is to insert this at line 84.
```
after(async function () {
clock.uninstall()
await sleep(5000)
})
```
Despite asserting that the promise rejects within the test, the promise
rejects after the test as well. Not entirely sure why this happening.
- Tried manually wrapping in try-catch with an `await` instead of
`assert.rejects` and it still fails.
- Tried wrapping the promise in another promise before passing to
`assert.rejects`.
## Solution
What does appear to work, is manually handling the callback of the
promise. That is, explicitly defining a `then` and `catch` method to
assert the rejection, and awaiting the promise at the end of the test to
ensure it resolves before the test finishes. Not sure why this works,
but I am unable to reproduce the error with this change.
## Notes
- `assert.rejects` implementation:
https://github.com/nodejs/node/blob/3178a762d6a2b1a37b74f02266eea0f3d86603be/lib/assert.js#L653.
Doesn't appear to be the problem because the same is observed when
manually wrapping.
- `await` docs:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await
---
<!--- REMINDER: Ensure that your PR meets the guidelines in
CONTRIBUTING.md -->
License: I confirm that my contribution is made under the terms of the
Apache 2.0 license.1 parent 2905eb8 commit c8bfe2f
File tree
2 files changed
+12
-10
lines changed- packages/core/src/test/credentials/sso
2 files changed
+12
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
11 | | - | |
| 11 | + | |
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| |||
Lines changed: 11 additions & 9 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
310 | 310 | | |
311 | 311 | | |
312 | 312 | | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
319 | | - | |
320 | 313 | | |
321 | 314 | | |
322 | 315 | | |
323 | 316 | | |
324 | 317 | | |
325 | 318 | | |
326 | 319 | | |
327 | | - | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
328 | 330 | | |
329 | 331 | | |
330 | 332 | | |
331 | 333 | | |
332 | 334 | | |
333 | | - | |
| 335 | + | |
334 | 336 | | |
335 | 337 | | |
336 | 338 | | |
| |||
0 commit comments