Skip to content

Conversation

alan-agius4
Copy link
Contributor

Resolves an issue where workers could be terminated while still in use due to an ordering problem between increasing worker usage and clearing the idle timeout. This caused AssertionError: 1 !== 0 during cleanup.

Closes #816

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

can you add a test for it?
Just to facilitate detect regressions

@alan-agius4
Copy link
Contributor Author

@metcoder95 I considered adding a test, but I'm not sure how to detect this specific case to ensure the timeout gets cleared earlier. Happy to include it if you have any suggestions!

Copy link
Member

@metcoder95 metcoder95 left a comment

Choose a reason for hiding this comment

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

Is a bit harder to get a good reproduction; here i'm assuming the problem roots to a high event loop lag that delay the execution of the timer callbacks leading to a race condition between the execution and the new task being posted.

Resolves an issue where workers could be terminated while still in use due to an ordering problem between increasing worker usage and clearing the idle timeout. This caused `AssertionError: 1 !== 0` during cleanup.

Closes piscinajs#816
@metcoder95 metcoder95 added the backport v5 Backport related with v5.x label Jun 19, 2025
@metcoder95 metcoder95 merged commit 5c24f4f into piscinajs:current Jun 19, 2025
12 checks passed
@alan-agius4 alan-agius4 deleted the terminate-worker branch June 19, 2025 09:16
@Tallyb
Copy link

Tallyb commented Jun 25, 2025

still getting it (building storybook with angular):

AssertionError [ERR_ASSERTION]: Expected values to be strictly equal:
1 !== 0
    at Timeout._onTimeout (.../node_modules/piscina/dist/index.js:317:39)
    at listOnTimeout (node:internal/timers:588:17)
    at process.processTimers (node:internal/timers:523:7) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: 1,
  expected: 0,
  operator: 'strictEqual'
}
Node.js v22.16.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport v5 Backport related with v5.x
Projects
None yet
Development

Successfully merging this pull request may close these issues.

workerInfo.idleTimeout not cleared in time, leading to AssertionError: 1 !== 0 since version 4.9.0
3 participants