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

fix(core): Ensure graceful shutdown for workers #9547

Merged

Conversation

ivov
Copy link
Contributor

@ivov ivov commented May 30, 2024

Comment on lines 486 to 497
if (process.stdout.isTTY) {
process.stdin.setRawMode(true);
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', (key: string) => {
// ctrl+c
if (key.charCodeAt(0) === 3) {
void this.stopProcess();
}
});
}
Copy link
Member

Choose a reason for hiding this comment

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

could this be moved to BaseCommand.init ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I understand, I think this is only needed for worker and webhook because of their never-resolving promise. start has its own process.stdin listener and I'd rather not change webhook in this PR about workers.

@@ -64,22 +64,22 @@ export class Worker extends BaseCommand {
this.logger.info('Stopping n8n...');

// Stop accepting new jobs
await Worker.jobQueue.pause(true);
void Worker.jobQueue.pause(true); // do not block so we can report progress
Copy link
Member

Choose a reason for hiding this comment

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

can we instead update queue.pause to pass the second argument (doNotWaitActive) as true instead of leaving a dangling promise here?

@n8n-assistant n8n-assistant bot added core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team labels May 30, 2024
Copy link

cypress bot commented May 31, 2024

1 flaky test on run #5214 ↗︎

0 359 0 0 Flakiness 1

Details:

🌳 🖥️ browsers:node18.12.0-chrome107 🤖 ivov 🗃️ e2e/*
Project: n8n Commit: 01f63296f9
Status: Passed Duration: 04:48 💡
Started: May 31, 2024 11:53 AM Ended: May 31, 2024 11:58 AM
Flakiness  cypress/e2e/5-ndv.cy.ts • 1 flaky test

View Output Video

Test Artifacts
NDV > should not retrieve remote options when required params throw errors Screenshots Video

Review all test suite changes for PR #9547 ↗︎

Copy link
Contributor

✅ All Cypress E2E specs passed

@ivov ivov merged commit 7fc00d8 into master May 31, 2024
30 checks passed
@ivov ivov deleted the pay-1580-bug-graceful-shutdown-does-not-seem-to-work-for-workers branch May 31, 2024 13:41
@github-actions github-actions bot mentioned this pull request Jun 3, 2024
@janober
Copy link
Member

janober commented Jun 3, 2024

Got released with n8n@1.44.1

@github-actions github-actions bot mentioned this pull request Jun 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core Enhancement outside /nodes-base and /editor-ui n8n team Authored by the n8n team Released
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants