-
Couldn't load subscription status.
- Fork 54
feat: add getUrl method to world implementations #60
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
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: e59e65e The changes in this PR will be included in the next version bump. This PR includes changesets to release 11 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
|
||
| return { queue, createQueueHandler, getDeploymentId }; | ||
| const getUrl: Queue['getUrl'] = () => { | ||
| return `https://${process.env.VERCEL_URL}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| return `https://${process.env.VERCEL_URL}`; | |
| const url = process.env.VERCEL_URL; | |
| if (!url) { | |
| throw new Error('VERCEL_URL environment variable is not set'); | |
| } | |
| return `https://${url}`; |
The getUrl() method doesn't validate that VERCEL_URL environment variable is set before using it, which will result in an invalid URL https://undefined if the variable is missing.
View Details
Analysis
Missing validation in Vercel world's getUrl() causes invalid URL when VERCEL_URL is undefined
What fails: Queue.getUrl() in packages/world-vercel/src/queue.ts returns the invalid URL https://undefined when the VERCEL_URL environment variable is not set, instead of validating the requirement like the parallel getDeploymentId() method does.
How to reproduce:
// In Vercel environment without VERCEL_URL set
delete process.env.VERCEL_URL;
const queue = createQueue();
const url = queue.getUrl(); // Returns "https://undefined"Result: Returns "https://undefined". This invalid URL is persisted to workflow metadata at packages/core/src/runtime.ts:588 via workflowMetadata: { url: world.getUrl() }.
Expected: Should validate that VERCEL_URL is set and throw an error (consistent with getDeploymentId() which throws when VERCEL_DEPLOYMENT_ID is missing), preventing invalid URLs from being persisted. The original code in packages/core/src/workflow.ts:94-97 had conditional logic with a fallback, indicating this environment variable may not always be available.
Fix: Added validation to getUrl() that throws an error when VERCEL_URL is not set, matching the pattern used by getDeploymentId() in the same file.
ea880da to
e59e65e
Compare
This PR introduces a
getUrlmethod to theQueueinterface and implements it across different world types (local, vercel, and postgres).getUrl()to the Queue interfaceruntime.tsto useworld.getUrl()instead of manually computing URLs