next.js: Next.js 8.1 has broken build: The "original" argument must be of type function

Bug report

Describe the bug

Since upgrading my version of next from 8.0.4 to 8.1, the next build command no longer works and the following is outputted:

“(node:1055) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError [ERR_INVALID_ARG_TYPE]: The “original” argument must be of type function (node:1055) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.”

Can confirm that this is a new bug, as downgrading next version back to 8.0.4 resolves the issue. The issue is not only present in my apps, but also the examples.

To Reproduce

  1. Clone the next.js repo.
  2. Change directory to /examples/custom-server.
  3. npm i.
  4. next run build.

And you’ll end up with the above error.

Expected behavior

A production-optimised build of the app is generated.

System information

  • OS: macOS
  • Version of Next.js: 8.1

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Reactions: 5
  • Comments: 18 (15 by maintainers)

Commits related to this issue

Most upvoted comments

I have the ~same~ problem. What is your node version @LoicVerrall? I’m running v11.10.0.

Edit: Actually my error is different, but the outcome is the same:

$ yarn build
yarn run v1.15.2
$ rimraf .next && next build
Creating an optimized production build ...

[00:08:47] Compiling client
[00:08:47] Compiling server
> Using external babel configuration
> Location: "/.../.babelrc"
(node:46139) UnhandledPromiseRejectionWarning: TypeError [ERR_INVALID_ARG_TYPE]: The "data" argument must be one of type string, Buffer, TypedArray, or DataView. Received type number
    at Hash.update (internal/crypto/hash.js:64:11)
    at ids.forEach.id (/.../node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:24:41)
    at Array.forEach (<anonymous>)
    at compilation.hooks.beforeChunkIds.tap.chunks (/.../node_modules/next/dist/build/webpack/plugins/hashed-chunk-ids-plugin.js:24:25)
    at SyncHook.eval [as call] (eval at create (/.../node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:12:1)
    at SyncHook.lazyCompileHook (/.../node_modules/tapable/lib/Hook.js:154:20)
    at hooks.optimizeTree.callAsync.err (/.../node_modules/webpack/lib/Compilation.js:1275:30)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/.../node_modules/tapable/lib/HookCodeFactory.js:32:10), <anonymous>:9:1)
    at AsyncSeriesHook.lazyCompileHook (/.../node_modules/tapable/lib/Hook.js:154:20)
    at Compilation.seal (/.../node_modules/webpack/lib/Compilation.js:1244:27)
(node:46139) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:46139) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
[00:09:06] Compiled server in 19s
✨  Done in 21.83s.

Excellent @stovmascript, can you send a PR removing that switch from the plugin? 🙏

@stovmascript actually, can you hand edit your node_modules/next/dist/build/webpack-config.js and find this line:

!dev && selectivePageBuilding && new AllModulesIdentifiedPlugin(dir)

and change it to:

!dev && new AllModulesIdentifiedPlugin(dir)

And report back if that fixes it? Thanks!

@MarchWorks I also tested on v10.10.0, but no go.

I think the examples are working because they don’t generate chunks that have ids which are just numbers.

shouldn’t you use the stable version of node v10.15.3 it’s the one that I used