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

Not working in nextjs middleware #349

Open
morgs32 opened this issue Jul 16, 2023 · 3 comments
Open

Not working in nextjs middleware #349

morgs32 opened this issue Jul 16, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@morgs32
Copy link

morgs32 commented Jul 16, 2023

Here is the error.

- error ./node_modules/@linear/sdk/dist/index-es.min.js:1:22
Module not found: Can't resolve 'http'

https://nextjs.org/docs/messages/module-not-found

Import trace for requested module:
./app/api/public/hello/route.ts
...

I assume it has to do with the graphql-request or isomorphic-unfetch dependencies. One of which is pulling in encoding...

@morgs32
Copy link
Author

morgs32 commented Jul 16, 2023

Ok it's obviously not graphql-request. I see that's for testing and that it's been forked to remove the external dependency in the build...

@guillaumelachaud
Copy link
Contributor

Do you have a bit more context on what you are attempting to do here? Are you trying to use the SDK in a Middleware route? Is this route a Linear webhook route?

@guillaumelachaud
Copy link
Contributor

guillaumelachaud commented Jul 21, 2023

I gathered a but more of information on the topic.
It looks like currently, middlewares run on the Edge Runtime for performance reasons. It is not possible to change the runtime used by Middlewares yet. There is an ongoing RFC to add support for this.

As you might know, the Edge Runtime doesn't support native Node.js APIs. As the Linear SDK has been designed as a Node.js SDK to run on the server, it, (or some of its dependencies), does rely on some Node.js native APIs.

Adding support for the Edge Runtime will require some amount of refactoring to identify and replace the said dependencies.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants