parcel: Build loop resulting in memory leak on importing image

🐛 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

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 2
  • Comments: 16 (6 by maintainers)

Most upvoted comments

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.

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.