Skip to content
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

🐛 Bug Report: @novu/framework: 2.4.0 Breaking imports #6954

Closed
2 tasks done
tmanick01 opened this issue Nov 12, 2024 · 8 comments · Fixed by #6983
Closed
2 tasks done

🐛 Bug Report: @novu/framework: 2.4.0 Breaking imports #6954

tmanick01 opened this issue Nov 12, 2024 · 8 comments · Fixed by #6983
Assignees
Labels

Comments

@tmanick01
Copy link

📜 Description

version 2.4.0 no longer exports the type Workflow, causing imports to break in typescript

👟 Reproduction steps

install latest @novu/framework
Try importinng the Workflow type

👍 Expected behavior

Type should be exported and should be accessible in client code, where type inference may not be straight forward, for example in a custom monorepo

👎 Actual Behavior with Screenshots

image

Novu version

Novu SaaS

npm version

9.5.1

node version

18.16.0

📃 Provide any additional context for the Bug.

No response

👀 Have you spent some time to check if this bug has been raised before?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to submit PR?

None

Copy link

linear bot commented Nov 12, 2024

@rifont
Copy link
Collaborator

rifont commented Nov 12, 2024

Firstly, apologies for this disruption!

Version 2.4.0 ships with a reduced public API focussed on improved DX with less noise. Specifically, we removed a lot of types from the public @novu/framework entry point. The Workflow type was not documented publicly on docs.novu.co and as such, this change was considered non-breaking.

We have an open PR (#6812) that will ship soon, providing InferWorkflowPayload and InferWorkflowId type inference utilities and re-exporting the Workflow type for user-land usage. At the same time we will publish docs.novu.co documentation for these types.

Could you please share your use-case for accessing the Workflow type? It will be useful for us to understand so we can create more useful type inference utilities in future iterations 🙏

In the interim, please import change your Workflow import to use the internal API:

import { Workflow } from `@novu/framework/internal`;

It's important to note that the @novu/framework/internal entry point is not stable and is subject to breaking changes.

@tmanick01
Copy link
Author

tmanick01 commented Nov 12, 2024

Thank you for the response @rifont. We have a plugin system and this error happens in the plugin we wrote for novu. The Workflow type is used in the interface declaration for that Plugin. We were able to work around that by using ReturnType, which solved the build failure.
Howevere another breaking behavior is that the sync via the cli seems to be broken :
image
trying the to test the workflow from the dashboard has the same error as well:

{ "statusCode": 500, "retryCount": 2, "message": "Internal Server Error", "raw": { "message": "Unknown BridgeError: crypto is not defined", "data": { "stack": "ReferenceError: crypto is not defined\n at Or (/usr/src/ms-notification/node_modules/@novu/framework/dist/cjs/servers/express.cjs:1:11777)\n at bt.validateHmac (/usr/src/ms-notification/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:6587)\n at bt.handleAction (/usr/src/ms-notification/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:4619)\n at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n at async /usr/src/ms-notification/node_modules/@novu/framework/dist/cjs/servers/express.cjs:95:3618" }, "code": "BridgeError" } }

Reverting @novu/framework: 2.3.0 fixes this, and everything works as before
image

@rifont
Copy link
Collaborator

rifont commented Nov 12, 2024

Thank you for sharing more information about your setup.

In 2.4.0 we replaced the internal usage of node:crypto module with the global Web crypto API to support edge runtimes like Cloudflare, which don't have access to Node APIs.

It appears that your runtime environment doesn't make that global crypto API available. Could you please share information about your runtime environment? The following will be helpful:

  • Runtime environment (e.g. Node, Cloudflare, Deno)
  • Runtime version

@rifont
Copy link
Collaborator

rifont commented Nov 12, 2024

Never mind the above, I see you are using Node 18 from the original description. Please raise a separate issue for the crypto issue and we'll assist there.

@rifont
Copy link
Collaborator

rifont commented Nov 13, 2024

I raised a new issue (#6982) for the crypto error.

@linear linear bot assigned rifont Nov 13, 2024
@tmanick01
Copy link
Author

Thank you @rifont , got side tracked with other priorities. Will add more details in the new issue soon.

@rifont
Copy link
Collaborator

rifont commented Nov 13, 2024

The Workflow type is now available in @novu/framework@2.5.0 🎉

import { Workflow } from '@novu/framework';

@linear linear bot closed this as completed Nov 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants