-
Notifications
You must be signed in to change notification settings - Fork 105
feat: add astro support #347
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: cdfbe27 The changes in this PR will be included in the next version bump. This PR includes changesets to release 10 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.
1 Skipped Deployment
|
8bd8782 to
13e7aa7
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This comment was marked as resolved.
This comment was marked as resolved.
| // Move past any routes with "continue: true" (like _astro cache headers) | ||
| while ( | ||
| insertIndex < config.routes.length - 1 && | ||
| config.routes[insertIndex + 1]?.continue === true | ||
| ) { | ||
| insertIndex++; |
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.
| // Move past any routes with "continue: true" (like _astro cache headers) | |
| while ( | |
| insertIndex < config.routes.length - 1 && | |
| config.routes[insertIndex + 1]?.continue === true | |
| ) { | |
| insertIndex++; | |
| // If filesystem handler is not found, insert at the end of routes | |
| if (insertIndex === -1) { | |
| insertIndex = config.routes.length - 1; | |
| } else { | |
| // Move past any routes with "continue: true" (like _astro cache headers) | |
| while ( | |
| insertIndex < config.routes.length - 1 && | |
| config.routes[insertIndex + 1]?.continue === true | |
| ) { | |
| insertIndex++; | |
| } |
Missing error handling when the "filesystem" route handler is not found in Astro's vercel output configuration, which could cause workflow routes to be inserted at the incorrect position in the routes array.
View Details
Analysis
Missing error handling when filesystem route handler is not found in Astro Vercel output configuration
What fails: VercelBuilder.build() at line 239-252 in packages/astro/src/builder.ts uses findIndex() to locate the "filesystem" route handler without validating it exists. When the route is missing, findIndex() returns -1, causing workflow routes to be inserted at index 0 instead of after the filesystem handler.
How to reproduce: Create an Astro project with Vercel deployment where the config.json lacks a route with handle: 'filesystem'. This can occur if:
- Custom Astro/Vercel integration doesn't add the filesystem handler
- Routes array is empty or malformed
- Astro version generates config differently than expected
Run the builder:
const vercelBuilder = new VercelBuilder();
await vercelBuilder.build();Result: When findIndex() returns -1:
- Loop condition
-1 < config.routes.length - 1evaluates to true insertIndexremains at -1config.routes.splice(-1 + 1, 0, ...WORKFLOW_ROUTES)splices at index 0- Workflow routes are inserted at the beginning of the routes array, not after the filesystem handler
Expected: Workflow routes should be inserted after the filesystem handler or at a safe fallback position (end of routes array), ensuring proper route precedence.
Reference: JavaScript Array.findIndex() returns -1 when no element matches the predicate, as documented in MDN Array.prototype.findIndex()
adds a new package
@workflow/astrofor supporting astrowaiting on Astro #14769 to be merged to resolve
TypeErrorbeing thrown coming from undefined unhandled rejectionsupdate: astro pr not needed if #384 is merged