-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add useJSONContent option for express and sveltekit #41
Conversation
* Whether the framework should use `content-type: application/json` | ||
* in `triggerFirstInvocation`. |
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.
I find this very confusing because we cannot assume anyone is familiar with our internal workings, they will not know what triggerFirstInvocation
is. To me a much more friendly approach would be directly specifying headers that are then forwarded, those can include the content type but are not limited
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.
useJSONContent is not part of the options we allow in serve
methods for frameworks (see PublicServeOptions). So it won't be visible to users unless they they import serve
from the route like import { serve } from "@upstash/workflow"
The reason we need this parameter is because we used to have publishJSON in client.trigger
. this didn't work because publishJSON adds content-type: application/json
, which breaks some frameworks. So we used publish
. But some frameworks still need the content type to be application/json
. sveltekit is one of them.
If you have a better alternative to the current implementation we can change it
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.
removed useJSONContent from the public API
When adding
nextjs-pages
integration, we realized that the QStash verification would fail because the bodies don't match. After inspection, here is what we saw:triggerFirstInvocation
which runs in theclient.trigger
or in the first workflow endpoint invocation addscontent-type: application/json
by default.{ "test" : "message" }
, QStash uses the whole string when creating signature.{"test":"message"}
because of thecontent-type
header.To fix the issue, we switched to
publish
intriggerFirstInvocation
.As a result of this however, some frameworks didn't work.
content-type: application/json
currently.content-type
wasn'tapplication/json
.