Skip to content

Commit

Permalink
chore: don't overwrite module-scoped constant
Browse files Browse the repository at this point in the history
  • Loading branch information
jedlikowski committed Sep 30, 2024
1 parent d93793d commit 98c2966
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions test/fn.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,19 +105,17 @@ test('timeout', async () => {
})

test('subsequent executions after timeout', async () => {
const SYNCKIT_TIMEOUT = 30
process.env.SYNCKIT_TIMEOUT = SYNCKIT_TIMEOUT.toString()
const executionTimeout = 30
process.env.SYNCKIT_TIMEOUT = executionTimeout.toString()

const { createSyncFn } = await import('synckit')
const syncFn = createSyncFn<AsyncWorkerFn>(workerCjsPath)

// start an execution in worker that will definitely time out
expect(() => syncFn(1, SYNCKIT_TIMEOUT * 3)).toThrow(
'Internal error: Atomics.wait() failed: timed-out',
)
expect(() => syncFn(1, executionTimeout * 3)).toThrow()

// wait for timed out execution to finish inside worker
await new Promise(resolve => setTimeout(resolve, SYNCKIT_TIMEOUT * 3))
await new Promise(resolve => setTimeout(resolve, executionTimeout * 3))

// subsequent executions should work correctly
expect(syncFn(2, 1)).toBe(2)
Expand Down

0 comments on commit 98c2966

Please sign in to comment.