OUT-3578: add afterIfAvailable utility for non-request contexts#219
Merged
SandipBajracharya merged 1 commit intomasterfrom Apr 10, 2026
Merged
OUT-3578: add afterIfAvailable utility for non-request contexts#219SandipBajracharya merged 1 commit intomasterfrom
SandipBajracharya merged 1 commit intomasterfrom
Conversation
Next.js after() throws when called outside a request scope (Trigger.dev, CLI scripts). Add afterIfAvailable() that tries after() and falls back to direct execution. Use it in getQBPortalConnection's notification path which runs in both Vercel serverless and Trigger.dev contexts. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
priosshrsth
approved these changes
Apr 10, 2026
Collaborator
priosshrsth
left a comment
There was a problem hiding this comment.
lgtm. Good to know. I have added after in all of repos as well.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
after()throws when called outside a request scope (Trigger.dev background jobs, CLI scripts).afterIfAvailable()utility that triesafter()and falls back to direct async execution when no request context is available.getQBPortalConnection()'s notification path inauth.service.ts, which runs in both Vercel serverless and Trigger.dev contexts.Changes
src/app/api/core/utils/afterIfAvailable.tsafter(), catches scope errors, falls back to direct execution with.catch()error loggingsrc/app/api/quickbooks/auth/auth.service.tsafterIfAvailablefor IU notification ingetQBPortalConnection;handleTokenExchangekeepsafter()(request-only)Test plan
resyncFailedRecordstask — verify notification fires withoutafter()scope errorafter()still defers the callback as before[afterIfAvailable] callback failed:🤖 Generated with Claude Code