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

[Bug]: Jobs worker test is flaky (fails indeterministically sometimes) #11873

Open
1 task done
Philzen opened this issue Dec 30, 2024 · 0 comments
Open
1 task done

[Bug]: Jobs worker test is flaky (fails indeterministically sometimes) #11873

Philzen opened this issue Dec 30, 2024 · 0 comments
Labels
bug/needs-info More information is needed for reproduction

Comments

@Philzen
Copy link
Contributor

Philzen commented Dec 30, 2024

Just a reminder to check

it('will try to find jobs in a loop until `forever` is set to `false`', async () => {

This sometimes fails with 3 calls instead of 2 – probably a race condition.

Failure log from https://cloud.nx.app/runs/B3Di6rkdxZ/task/%40redwoodjs%2Fjobs%3Atest

✓ src/core/__tests__/Scheduler.test.ts  (12 tests) 70ms 9 MB heap used
 ✓ src/adapters/PrismaAdapter/__tests__/PrismaAdapter.test.ts  (21 tests) 141ms 11 MB heap used
 ✓ src/core/__tests__/JobManager.test.ts  (13 tests) 65ms 10 MB heap used
 ❯ src/core/__tests__/Worker.test.ts  (28 tests | 1 failed) 113ms 12 MB heap used
   × run > will try to find jobs in a loop until `forever` is set to `false`
     → expected "spy" to be called 2 times, but got 3 times
 ✓ src/core/__tests__/Executor.test.ts  (11 tests) 53ms 9 MB heap used
 ✓ src/adapters/BaseAdapter/__tests__/BaseAdapter.test.ts  (2 tests) 4ms 8 MB heap used
 ✓ src/bins/__tests__/rw-jobs-worker.test.ts  (4 tests) 8ms 11 MB heap used
 ✓ src/bins/__tests__/rw-jobs.test.ts  (6 tests) 10ms 11 MB heap used
 ✓ src/__tests__/setupEnv.test.ts  (2 tests) 4ms 8 MB heap used

⎯⎯⎯⎯⎯⎯⎯ Failed Tests 1 ⎯⎯⎯⎯⎯⎯⎯

 FAIL  src/core/__tests__/Worker.test.ts > run > will try to find jobs in a loop until `forever` is set to `false`
AssertionError: expected "spy" to be called 2 times, but got 3 times
 ❯ src/core/__tests__/Worker.test.ts:301:26
    299|     await new Promise((resolve) => setTimeout(resolve, 20))
    300|     worker.forever = false
    301|     expect(adapter.find).toHaveBeenCalledTimes(2)
       |                          ^
    302|   })
    303| 

Are you interested in working on this?

  • I'm interested in working on this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug/needs-info More information is needed for reproduction
Projects
None yet
Development

No branches or pull requests

1 participant