Skip to content

[Bug]: ___netlify-handler fails with boilerplate NX Mono Repo #1278

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

Closed
2 tasks
Joroze opened this issue Mar 23, 2022 · 6 comments · Fixed by #1281
Closed
2 tasks

[Bug]: ___netlify-handler fails with boilerplate NX Mono Repo #1278

Joroze opened this issue Mar 23, 2022 · 6 comments · Fixed by #1281
Labels
type: bug code to address defects in shipped code

Comments

@Joroze
Copy link

Joroze commented Mar 23, 2022

Summary

After minimal NX Workspace setup with a boilerplate NextJS project generated, ___netlify-handler errors out/fails for all invokations, despite successful deployment.

TLDR: NextJS API Routes are not working, due to ___netlify-handler errors.

{"errorType":"Error","errorMessage":"ENOENT: no such file or directory, chdir '/var/task' -> '/var/task/apps/frontend'","trace":["Error: ENOENT: no such file or directory, chdir '/var/task' -> '/var/task/apps/frontend'"," at process.wrappedChdir [as chdir] (internal/bootstrap/switches/does_own_process_state.js:116:14)"," at /var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:19:13"," at Object.<anonymous> (/var/task/.netlify/functions-internal/___netlify-handler/___netlify-handler.js:106:3)"," at Module._compile (internal/modules/cjs/loader.js:1085:14)"," at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)"," at Module.load (internal/modules/cjs/loader.js:950:32)"," at Function.Module._load (internal/modules/cjs/loader.js:790:12)"," at Module.require (internal/modules/cjs/loader.js:974:19)"," at require (internal/modules/cjs/helpers.js:93:18)"," at Object.<anonymous> (/var/task/___netlify-handler.js:1:18)"]}

Steps to reproduce

npx create-nx-workspace nx-netlify-test
npx: installed 48 in 2.008s
✔ What to create in the new workspace · next
✔ Application name                    · frontend
✔ Default stylesheet format           · @emotion/styled
✔ Use Nx Cloud? (It's free and doesn't require registration.) · No

 >  NX   Nx is creating your v13.9.4 workspace.

Add a general api route /api/index.tsx

export default function handler(req, res) {
  res.status(200).json({
    body: 'Hello world',
  });
}

Deployed using Netlify Web GUI

A link to a reproduction repository

https://github.com/Joroze/nx-netlify-test

Plugin version

4.2.8

More information about your build

  • I am building using the CLI
  • I am building using file-based configuration (netlify.toml)

What OS are you using?

No response

Your netlify.toml file

`netlify.toml`
# Paste content of your `netlify.toml` file here

Your public/_redirects file

`_redirects`
# Paste content of your `_redirects` file here

Your next.config.js file

`next.config.js`
// eslint-disable-next-line @typescript-eslint/no-var-requires
const withNx = require('@nrwl/next/plugins/with-nx');

/**
 * @type {import('@nrwl/next/plugins/with-nx').WithNxOptions}
 **/
const nextConfig = {
  nx: {
    // Set this to true if you would like to to use SVGR
    // See: https://github.com/gregberge/svgr
    svgr: false,
  },
};

module.exports = withNx(nextConfig);

Builds logs (or link to your logs)

Build logs
https://app.netlify.com/sites/delightful-sunburst-c3897b/deploys/623b28398dc14d008c668b54

Function logs

Function logs
https://delightful-sunburst-c3897b.netlify.app/.netlify/functions/___netlify-handler

.next JSON files

generated .next JSON files
# Paste file contents here. Please check there isn't any private info in them
# You can either build locally, or download the deploy from Netlify by clicking the arrow next to the deploy time.
@Joroze Joroze added the type: bug code to address defects in shipped code label Mar 23, 2022
@Joroze Joroze changed the title [Bug]: NX Workspaces does not work using [Bug]: ___netlify-handler fails with NX Workspaces Mar 23, 2022
@Joroze Joroze changed the title [Bug]: ___netlify-handler fails with NX Workspaces [Bug]: ___netlify-handler fails with minimal NX Mono Repo setup Mar 23, 2022
@Joroze Joroze changed the title [Bug]: ___netlify-handler fails with minimal NX Mono Repo setup [Bug]: ___netlify-handler fails with boilerplate NX Mono Repo Mar 23, 2022
@ascorbic
Copy link
Contributor

ascorbic commented Mar 23, 2022

Thanks for the report. This looks like it was a regression introduced in version 4.2.8 of the plugin. Could you try downgrading it to 4.2.7 and see if that fixes it for now?

@aruke
Copy link

aruke commented Mar 23, 2022

I'm having the same error after upgrading the plugin in UI.
How do I downgrade the version? Do I have to specify it in netlify.toml file?

@ascorbic
Copy link
Contributor

Hey. You shoudl install it in your package.json. Something like npm i -D @netlify/[email protected]

@Joroze
Copy link
Author

Joroze commented Mar 23, 2022

Thanks for the report. This looks like it was a regression introduced in version 4.2.8 of the plugin. Could you try downgrading it to 4.2.7 and see if that fixes it for now?

Hey. You shoudl install it in your package.json. Something like npm i -D @netlify/[email protected]

Doing the following fixes my issues. Hopefully latest version of the plugin is fixed soon! Thanks @ascorbic!

@aruke
Copy link

aruke commented Mar 23, 2022

Same here, downgrading the plugin solved the issue.
I also found the related docs link: https://docs.netlify.com/configure-builds/build-plugins/#manage-plugin-versions

@igndev10
Copy link

Thanks for the report. This looks like it was a regression introduced in version 4.2.8 of the plugin. Could you try downgrading it to 4.2.7 and see if that fixes it for now?

This worked for me. For those who don't have netlify.toml currently, no need to add other configs, just add the [[plugin]] and it will still build.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants