Skip to content

Conversation

@CahidArda
Copy link
Collaborator

as we migrate from @upstash/qstash, there are some backwards incompatible changes we want to make.

These will be explained in the migration guide. To briefly explain them here:

  • change serve method returns to allow const { POST } = serve(...)
  • update context.call parameters and return
// old
const result = await context.call("call step", "<call-url>", "POST", ...)

// new
const {
  status,  // response status
  headers, // response headers
  body     // response body
} = await context.call("call step", {
  url: "<call-url>",
  method: "POST",
  ...
})

now, it will be possible to extend the serve method in the future as it returns const { POST } = serve(...).

it isn't changed in hono, as it doesn't fit the hono syntax.
@linear
Copy link

linear bot commented Oct 17, 2024

},
"dependencies": {
"@upstash/qstash": "latest",
"@upstash/workflow": "^0.1.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldnt we get the package from ../../dist as above?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated all imports with canary

{
destination: WORKFLOW_ENDPOINT,
headers: {
"upstash-feature-set": "WF_NoDelete",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this header do? Just to know

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In @upstash/qstash, if the request in context.call failed, the workflow run would fail and failure handlers would be called.

Now, we don't want to make the workflow run fail, but we want to continue from where we left off. This header tells the qstash-server that this workflow is from the new sdk, and run shouldn't fail

*/
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-parameters
public async call<TResult = unknown, TBody = unknown>(
public async call(
Copy link
Contributor

@fahreddinozcan fahreddinozcan Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did we remove the generic typing here? I think it's nice to have the option of const res = call<T>() instead of const res = call() as T

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

to get rid of no-unnecessary-type-parameters warning

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could also disable that rule for this page

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yusuf was suggesting removing it, how about removing it for now and adding it later?

We can add it later but can't remove it later. I want to think about this a bit more because there is no generic in await request.json() for instance

body?: TBody,
headers?: Record<string, string>
) {
callSettings: {
Copy link
Contributor

@fahreddinozcan fahreddinozcan Oct 17, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we can call this just settings

try {
const body = JSON.parse(result);
return {
status: -1,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we return status -1 on succesful request?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it could be anything from 200 to 299, so I didn't want to return anything, but let's go with 200.

* @returns A promise that resolves to a response.
*/
const handler = async (request: TRequest) => {
await debug?.log("INFO", "ENDPOINT_START");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this redundant?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it indicates that the endpoint was called and is executing

notifyResponse: NotifyResponse[];
};

export type CallResponse = {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should have generics

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you mean for body field right? This is the same issue as whether we want to have await context.call<SomeType>. I would like to think a bit more before adding this

@CahidArda CahidArda merged commit 306d4cc into main Oct 18, 2024
@CahidArda CahidArda deleted the DX-1312-backwards-incompatible-changes branch October 18, 2024 08:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants