Parcel: Build loop resulting in memory leak on importing image

Created on 10 Aug 2020  ยท  15Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report


importing an image via import hamster from 'url:./img/NotFound/hamster.png results in a build loop, which in turn causes a memory leak.

๐ŸŽ› Configuration (.babelrc, package.json, cli command)

"babel": {
  "presets": [
    "@babel/preset-typescript",
    "babel-preset-nano-react-app"
  ]
}

from nano-react-app/nano-react-app

๐Ÿค” Expected Behavior


... Image gets imported, no build loop.

๐Ÿ˜ฏ Current Behavior


parcel index.html results in a build loop. No error is printed and the page imports the image properly.

๐Ÿ’ Possible Solution


ยฏ\_(ใƒ„)_/ยฏ

๐Ÿ”ฆ Context


Importing an image and using it via <img src={hamster} />. This is pretty basic usage.

๐Ÿ’ป Code Sample

import * as React from "react";
import { Link } from "react-router-dom";

import hamster from 'url:./img/NotFound/hamster.png';

export default class NotFound extends React.Component {
    render() {
        return (
            <div>
                <h1>Page not found</h1>
                <h2>Make sure you entered the link correctly.</h2>
                <div>
                    <img src={hamster} />
                    <Link to="/" className="button">Back home</Link>
                </div>
            </div>
        );
    }
}

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | ^2.0.0-alpha.3.2
| Node | v12.16.3
| npm/Yarn | Yarn 1.22.4
| Operating System | Fedora 32

Bug โœจ Parcel 2

All 15 comments

Please provide a more complete code sample (ideally a repository) to reproduce this

Please provide a more complete code sample (ideally a repository) to reproduce this

kotx/parcel-memleak-demo

@mischnic CC ^

I've provided a repository to reproduce the bug. Please remove the waiting label?

I got exactly the same issue. When I start I get this error:

MaxListenersExceededWarning: Possible EventEmitter memory leak detected. 13 error listeners added to [WriteStream]. Use emitter.setMaxListeners() to increase limit.

Then it says built in x ms and goes back to bundling. Those builds are all around 200ms. Meanwhile my rams filling up like crazy.

I've provided a repository to reproduce the bug.

Works fine on macOS. I'll have to test with Linux...

I don't get a build loop in a Fedora VM either...

@mischnic That's strange, could you perhaps test the repository in #5178?

I'm using Windows Insiders 2004 with VSCode, if that matters. Node version v14.5.0.

You mean as a VM host or that you experienced this on both OSs?

Windows Insiders 2004

Operating System | Fedora 32

could you perhaps test the repository in #5178?

Same behavior: when starting Parcel in serve mode, it builds and then idles after the first build: Built in 32s.

You mean as a VM host or that you experienced this on both OSs?

Windows Insiders 2004

Operating System | Fedora 32

Oh my bad, I experienced this on both OSes, yes.

I am having the same issue. For me, deleting the .parcel-cache usually fixes it for a couple of days, after which the issue reappears. I was unable to isolate which code change exactly causes the problem.
Windows 10 2004 user here.

Hello, I am experiencing the same issue. I cannot provide a comprehensive code sample because my issue is within my employer's codebase. However, it surfaces as soon as I import a PNG using the following line:

import Logo from 'url:../assets/logo.png';

It is not resolved by removing the import and restarting the build (parcel serve). It is only resolved by removing the import, stopping the build, deleting .parcel-cache, and then resuming the build. I have not seen it resurface after doing that, but I have not attempted any further image imports.

  • Ubuntu 18.04.5 LTS
  • Parcel 2.0.0-beta.1
  • Node v10.22.1
  • npm v6.14.6

Thank you.

I have similar issue but in my case the builder flips over when I try to import component from JS file stored outside of the root folder of the project.
I got not only tones of memory leaks errors but also bunch of other errors, package.json gets wiped completely and parcel.exe gets removed from .bin folder.
I will create a new issue later once I will find a spare minute to create reproducible repo. Just giving you heads up in case it's somehow related.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jsftw86 picture jsftw86  ยท  3Comments

termhn picture termhn  ยท  3Comments

Niggler picture Niggler  ยท  3Comments

algebraic-brain picture algebraic-brain  ยท  3Comments

mnn picture mnn  ยท  3Comments