blomqma / next-rest-framework

Type-safe, self-documenting APIs for Next.js
https://next-rest-framework.vercel.app
Other
134 stars 18 forks source link

Error upgrading from NRF 4 to 5: next_dist_server_web_exports_next_response__WEBPACK_IMPORTED_MODULE_3__ #127

Closed SaadBazaz closed 6 months ago

SaadBazaz commented 6 months ago

I get a little trigger-happy when I see a new update.

Problem is, this time it broke my app and I can't understand why.

Here's the issue:

Next REST Framework encountered an error:
TypeError: next_dist_server_web_exports_next_response__WEBPACK_IMPORTED_MODULE_3__ is not a constructor
 ⨯ TypeError: next_dist_server_web_exports_next_response__WEBPACK_IMPORTED_MODULE_3__.json is not a function
    at handler (webpack-internal:///(rsc)/../../node_modules/.pnpm/next-rest-framework@5.1.0_next@14.0.4_zod@3.22.4/node_modules/next-rest-framework/dist/index.mjs:431:92)
    at /Users/saadbazaz/Projects/omni-tools/node_modules/.pnpm/next@14.0.4_@babel+core@7.23.9_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/next-server/app-route.runtime.dev.js:6:63257
    at /Users/saadbazaz/Projects/omni-tools/node_modules/.pnpm/next@14.0.4_@babel+core@7.23.9_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/server/lib/trace/tracer.js:133:36
    at NoopContextManager.with (/Users/saadbazaz/Projects/omni-tools/node_modules/.pnpm/next@14.0.4_@babel+core@7.23.9_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:7062)
    at ContextAPI.with (/Users/saadbazaz/Projects/omni-tools/node_modules/.pnpm/next@14.0.4_@babel+core@7.23.9_react-dom@18.2.0_react@18.2.0/node_modules/next/dist/compiled/@opentelemetry/api/index.js:1:518)

In a screenshot:

Screenshot 2024-02-14 at 19 39 22

Happens whenever I access /api

blomqma commented 6 months ago

Yeah I just noticed the same issue, this is related to the changes of considering Next.js as a peer dependency when building the production bundle of the library, should've created an experimental release to test this first... Anyways, this is now fixed in v5.1.1, so upgrading to that should work.

blomqma commented 6 months ago

@SaadBazaz Looks like the attempted fix in v5.1.1 did't resolve the issue, v5.1.2 is now live that contains a working fix.

blomqma commented 6 months ago

@SaadBazaz Looks like the attempted fix in v5.1.1 did't resolve the issue, v5.1.2 is now live that contains a working fix.

And due to the same recent changes there was also another issue that might cause next build to fail depending on your environment, so upgrading to v5.1.3 addresses that as well.

SaadBazaz commented 6 months ago

/API works now!

However, some routes aren't visible at all, even though their structure is similar to the others and they're not in ignored

blomqma commented 6 months ago

/API works now!

However, some routes aren't visible at all, even though their structure is similar to the others and they're not in ignored

For this issue I need more information. Generating the OpenAPI spec with the CLI, the documentation and calling the API endpoints seem to work fine in my environment with v5.1.3. Can you describe further about your problem about your API routes not being visible and how to reproduce it.