-
Notifications
You must be signed in to change notification settings - Fork 106
Feat: fastify support with nitro #386
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
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
|
|
@eersnington is attempting to deploy a commit to the Vercel Labs Team on Vercel. A member of the Team first needs to authorize it. |
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Stream web streams the same way express or hono do. Read the web reader and write each json chunk to reply.raw. Avoids fastifys async iterator quirks that reordered frames and sent undefined data in the output stream tests Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
| if (!workflowFile) { | ||
| return reply.code(400).send('No workflowFile query parameter provided'); | ||
| } | ||
| const workflows = allWorkflows[workflowFile as keyof typeof allWorkflows]; | ||
| if (!workflows) { | ||
| return reply.code(400).send(`Workflow file "${workflowFile}" not found`); | ||
| } | ||
|
|
||
| const workflowFn = (req.query.workflowFn as string) || 'simple'; | ||
| if (!workflowFn) { | ||
| return reply.code(400).send('No workflow query parameter provided'); | ||
| } |
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.
| if (!workflowFile) { | |
| return reply.code(400).send('No workflowFile query parameter provided'); | |
| } | |
| const workflows = allWorkflows[workflowFile as keyof typeof allWorkflows]; | |
| if (!workflows) { | |
| return reply.code(400).send(`Workflow file "${workflowFile}" not found`); | |
| } | |
| const workflowFn = (req.query.workflowFn as string) || 'simple'; | |
| if (!workflowFn) { | |
| return reply.code(400).send('No workflow query parameter provided'); | |
| } |
The parameter validation checks on lines 67-68 and 76-77 are dead code and will never execute, because the variables are always assigned non-empty default values using the OR operator above them.
View Details
Analysis
Dead code: unreachable validation checks in POST /api/trigger endpoint
What fails: Lines 67-68 and 76-77 in workbench/fastify/src/index.ts contain unreachable validation checks that will never execute.
How to reproduce: The following code pattern causes dead code because the OR operator guarantees non-falsy values:
const workflowFile = (req.query.workflowFile as string) || 'workflows/99_e2e.ts';
if (!workflowFile) { // This condition will never be true
return reply.code(400).send('No workflowFile query parameter provided');
}When req.query.workflowFile is undefined, the expression (undefined || 'workflows/99_e2e.ts') evaluates to the default string 'workflows/99_e2e.ts', which is truthy. The subsequent if (!workflowFile) check will never execute.
Result: Dead code remains in the codebase, creating confusion about intended behavior.
Expected: Since default values are intentionally provided via the OR operator, the validation checks should be removed. The defaults indicate the developer intended these parameters to be optional, making the checks that assume they might be missing logically inconsistent.
Fix: Removed the unreachable validation checks on lines 67-68 and 76-77, keeping only the default value assignments and the subsequent existence checks on the workflow lookup (lines 68-70 and 74-77), which properly validate that the assigned workflow file and function actually exist.
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.
Technically correct nit, but this pattern is consistent across all the api/trigger (POST) routes in all benches. Is this change necessary?
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
Signed-off-by: Sree Narayanan <[email protected]>
|
I'll wait for a review before updating test matrix and local-build.test.ts CI? |


Cooked up a working demo of using workflow devkit with fastify, using nitro as the bundler. I will add a docs page and e2e tests as well (following adrian's example for express).
Really quick guide
1. Configure Nitro
Configure
nitro.config.tsto load the workflow module and direct all routes to your entry file.2. Server Entry Adapter
In your entry file, bridge Nitro to Fastify by manually emitting the request event to Fastify's underlying server instance.
3. Create Workflows
Import your workflow and call
start()within any standard Fastify route handler.