Skip to content

fix(api): recover NuQ RabbitMQ listeners after subscription failures - #5923

Open
JasonOA888 wants to merge 4 commits into
firecrawl:mainfrom
JasonOA888:devin/1795181912-nuq-rabbitmq-listener
Open

JasonOA888 wants to merge 4 commits into
firecrawl:mainfrom
JasonOA888:devin/1795181912-nuq-rabbitmq-listener

Conversation

@JasonOA888

@JasonOA888 JasonOA888 commented Nov 20, 2026 •

Copy link
Copy Markdown

Summary

Fixes #4244. NuQ now waits for RabbitMQ to accept the consumer before making the listener available to job waiters. Concurrent waiters share the same startup attempt. If setup fails, NuQ closes the partial channel and connection, reports the original error, and lets the next waiter retry.

Deliveries are acknowledged on the channel that received them, including messages delivered immediately after registration. When the broker cancels an established consumer, NuQ closes the old connection before reconnecting and checks PostgreSQL for completions that arrived while disconnected.

Continues #4263 against current main. Thanks to @edenbuilds and @omkar1work for the original fix and cleanup work.

Testing

  • The new listener unit regression failed on unmodified main. All seven listener tests pass with the fix, covering retry, concurrent waiters, cancellation, startup shutdown, and timeouts.
  • pnpm harness pnpm exec vitest run src/__tests__/nuq-postgres.test.ts passed all three tests, including an actual broker rejection followed by a PostgreSQL-backed job completion delivered through RabbitMQ. The harness also built the API.
  • The pre-commit hook passed. pnpm test:core had 1,152 passes, 26 skips, and one unrelated HTML-to-Markdown list-formatting failure, reproduced separately on unmodified main.

Summary by cubic

NuQ RabbitMQ listeners now wait for the broker to accept the consumer before becoming available to job waiters, wait for listener shutdown to finish, and recover when subscriptions or reconnects fail.

Bug Fixes

  • Concurrent waiters share the same startup attempt; failures close the partial channel and connection and let the next waiter retry.
  • Deliveries are acknowledged on the channel that received them, including messages that arrive before consume() resumes.
  • After a broker cancellation, NuQ closes the old connection, reconciles missed completions from PostgreSQL, and reconnects with exponential backoff.
  • Shutdown awaits an in-flight startup or reconnect, bounded by a 5-second deadline, and cancels scheduled reconnects.

Written for commit 4ea8d53. Summary will update on new commits.

View guided diff

Continue firecrawl#4263 against current main and verify subscription recovery with RabbitMQ and Postgres.

Co-authored-by: edenbuilds <[email protected]>
Co-authored-by: omkar1work <[email protected]>
cubic-dev-ai[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Devin Review

cubic-dev-ai[bot]

This comment was marked as resolved.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Auto-approved with 1 open P3 issue.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

0 issues found across 1 file (changes from recent commits).

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

View guided diff | Re-trigger cubic

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

api: NuQ channel.consume() outside try/finally permanently breaks the RabbitMQ listener — all waitForJob calls hang after one consume() failure

1 participant