Parcel: UnhandledPromiseRejectionWarning when building.

Created on 5 Dec 2017  ยท  18Comments  ยท  Source: parcel-bundler/parcel

Hi. As many others I am very excited for the work you are doing here. Badly needed.
I have stumpled upon a slight problem building even just the simplest html file:

<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <title></title>
  </head>
  <body>
    <p>Hello...</p>
  </body>
</html>

After running parcel index.html, the "dist" folder is created but it is empty.
The following is the console errors:

Server running at http://localhost:1234
โณ  Building index.html...
(node:11164) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3001): RangeError: Maximum call stack size exceeded
(node:11164) [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.
Bug Windows

Most helpful comment

Published v1.0.3.

All 18 comments

Confirming this happens to me as well. Node 9.1.0

hmm, is this node 9 specific? I've tested against node 8 so far.

Happens to me in both 8 and 9.

On Tue, 5 Dec 2017, 20.58 Devon Govett, notifications@github.com wrote:

hmm, is this node 9 specific? I've tested against node 8 so far.

โ€”
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/parcel-bundler/parcel/issues/11#issuecomment-349422720,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAtB7XdvEgBfcGop83_v38GthMB2mz1Fks5s9aBSgaJpZM4Q23fJ
.

Same here. I just followed get-started guide as it failed. :cry:
Dist folder is also created.

parcel --version => 1.0.1
node --version => v9.2.0
platform => windows 10 pro x64

Error

Server running at http://localhost:1234
โณ  Building index.html...
(node:2520) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 3001): 
RangeError: Maximum call stack size exceeded
(node:2520) [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.

Steps to reproduce:

// module.js
export function helloWorld () {console.log('Hello World!');};

```javascript
// index.js
import { helloWorld } from './module';
helloWorld();

```html
    <script src="index.js"></script>

Command

$ parcel index.html

I followed the getting started and had the same results. Sample repo here: https://github.com/mwarger/parcel-getting-started-windows

Windows 10

parcel 1.0.1
node 9.2.0

This happens even with the simplest html file and no JS involved:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Test</title>
</head>
<body>
  <div id="app"/>

</body>
</html>

node v7.10.0
[email protected]

I get the same error. When I try to do a build on the Windows subsystem for Linux, the error goes away (but I get a new one, related: https://github.com/parcel-bundler/parcel/issues/8)

๐Ÿšจ  /mnt/d/Projects/parcel-test/index.js: MOZ_TO_ME[node.type] is not a function
    at from_moz (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10753:54)
    at Object.From_Moz_AssignmentExpression [as AssignmentExpression] (eval at map (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1)), <anonymous>:9:8)    at from_moz (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10753:54)
    at Object.ExpressionStatement (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10292:23)
    at from_moz (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10753:54)
    at Array.map (<anonymous>)
    at Object.Program (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10267:51)
    at from_moz (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10753:54)
    at Function.AST_Node.from_mozilla_ast (eval at <anonymous> (/mnt/d/Projects/parcel-test/node_modules/uglify-js/tools/node.js:21:1), <anonymous>:10761:19)
    at module.exports (/mnt/d/Projects/parcel-test/node_modules/parcel-bundler/src/transforms/uglify.js:10:22)

So it does appear to be a Windows issue.

For people on Windows, WSL seems like a workaround for the time being. I got it to build with the --no-minify flag.

hmm, seems like a windows issue ๐Ÿ˜ข? I can try to setup a vm to test, but would be great if someone could dig into this a bit and get more info on the errors being logged there (e.g. what promise is being rejected, etc.). Thanks in advance for your help! ๐Ÿ˜„

@devongovett It turns out that src/utils/config.js#L6 got recursively calling itself, which causes Maximum call stack size exceeded. Not find out how to solve it yet.
I got this information by mocha, here is the stack trace:

test/css.js#L8 in describe('css', function () {

    let b = await bundle(__dirname + '/integration/css/index.js');

src/Bundler.js#L275 in async loadAsset(asset) {

      processed = await this.farm.run(asset.name, asset.package, this.options);

src/WorkerFarm.js#L63 in async run(...args) {

      return this.localWorker.run(...args);

src/worker.js#L20 in exports.run = async function (path, pkg, options, callback) {

    await asset.process();

src/assets/JSAsset.js#L72 in async pretransform() {

    await babel(this);

src/transforms/babel.js#L39 in async function shouldTransform(asset) {

  let babelrc = await config.resolve(asset.name, ['.babelrc', '.babelrc.js']);

src/utils/config.js#L25 in async function resolve(filepath, filenames, root = '/') {

  return resolve(filepath, filenames, root);

src/utils/config.js#L25

resolve(filepath, filenames, root);

Let's look at the return value in Windows and Mac environments.

This is windows screenshot

image

In src/utils/config.js#L10, I did:
replace filepath === root with filepath === root || filepath === path.dirname(filepath),
then I run test again, got these:


> mocha

css
โˆš should produce two bundles when importing a CSS file (2301ms)
โˆš should support loading a CSS bundle along side dynamic imports (1234ms)
โˆš should support importing CSS from a CSS file
โˆš should support linking to assets with url() from CSS
1) should support transforming with postcss
โˆš should minify CSS in production mode (325ms)

fs
โˆš should inline a file as a string
โˆš should inline a file as a buffer (113ms)
โˆš should inline a file with fs require alias
โˆš should inline a file with fs require inline
โˆš should inline a file with fs require assignment
โˆš should inline a file with fs require assignment alias
โˆš should inline a file with fs require destructure
โˆš should inline a file with fs require destructure assignment

glob
2) should require a glob of files
3) should require nested directories with a glob
4) should support importing a glob of CSS files

hmr
โˆš should emit an HMR update for the file that changed (207ms)
5) "before each" hook for "should emit an HMR update for all new dependencies along with the changed file"

14 passing (5s)
5 failing

1) css
should support transforming with postcss:

AssertionError [ERR_ASSERTION]: '_index_1cehs_1' == '_index_1ezyc_1'
+ expected - actual

-_index_1cehs_1
+_index_1ezyc_1

at Context.<anonymous> (test\css.js:119:12)
at <anonymous>

2) glob
should require a glob of files:
TypeError: Cannot read property 'name' of undefined
at assertBundleTree (test\utils.js:63:39)
at Context.<anonymous> (test\glob.js:9:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

3) glob
should require nested directories with a glob:
TypeError: Cannot read property 'name' of undefined
at assertBundleTree (test\utils.js:63:39)
at Context.<anonymous> (test\glob.js:23:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

4) glob
should support importing a glob of CSS files:
TypeError: Cannot read property 'name' of undefined
at assertBundleTree (test\utils.js:63:39)
at Context.<anonymous> (test\glob.js:37:5)
at <anonymous>
at process._tickCallback (internal/process/next_tick.js:188:7)

5) "before each" hook for "should emit an HMR update for all new dependencies along with the changed file":
Error: ENOTEMPTY: directory not empty, rmdir 'D:\inbox\parcel\test\dist'
at Object.fs.rmdirSync (fs.js:846:18)
at rmkidsSync (node_modules\rimraf\rimraf.js:356:25)
at rmdirSync (node_modules\rimraf\rimraf.js:334:7)
at Function.rimrafSync [as sync] (node_modules\rimraf\rimraf.js:304:9)
at Context.<anonymous> (test\utils.js:10:10)

It's probably that root is /, but on Window file paths are split up by \ and I think the root of the file system has a prefix?

@thejameskyle exactly, I created a PR https://github.com/parcel-bundler/parcel/pull/48 which fix it but test are still failing. We should integrate CI.

Same for node v7.9.0, win10 x64, parcel 1.2

when we can use the version 1.0.3 ?

Published v1.0.3.

Just for what it's worth I got this exact same error trying parcel on MacOS High Sierra with a minimum HTML page and Node 6x latest. Looks like Parcel requires >= 8x, as switching from Boron to Carbon fixed it. Would probably be worth noting this on the docs, as I couldn't find anything indicating which version of Node was required.

same issue here with
OS: macOS 10.15(13-inch, 2017, i5+8+256) nodejs: v10.15.3 parcel-bundler: 1.12.4

----- updates: -----
found that issue above cause my code of page-main.js:
````
//deps:
import Vue from 'vue'

//main:
if(missing required search query) return false
const vm= new Vue({
//...ANY CODE
})
`` and it worked for me when i removedif(missing required search query) return false`` this line.
maybe i need some work around code~ sorry for bothering here~ :P

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jzimmek picture jzimmek  ยท  3Comments

oliger picture oliger  ยท  3Comments

davidnagli picture davidnagli  ยท  3Comments

algebraic-brain picture algebraic-brain  ยท  3Comments

adamreisnz picture adamreisnz  ยท  3Comments