Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

2.6.1 - 2.6.2: build error @parcel/compressor-raw: Cannot read properties of undefined (reading 'on') #8257

Closed
aldrakos opened this issue Jun 27, 2022 · 18 comments

Comments

@aldrakos
Copy link

馃悰 bug report

After trying to update to parcel 2.6.1 and 2.6.2, when trying to build we get an error of @parcel/compressor-raw: Cannot read properties of undefined (reading 'on') . It's an error that happens when packaging different types of files (from .js to .ico to image assets)). Everything works fine on parcel 2.6.0.

馃帥 Configuration (.babelrc, package.json, cli command)

We're using the following .parcelrc:

{
  "extends": "@parcel/config-default",
  "transformers": {
    "*.{js,mjs,jsx,cjs,ts,tsx}": [
      "@parcel/transformer-js",
      "@parcel/transformer-react-refresh-wrap"
    ]
  }
}

馃 Expected Behavior

After updating to parcel 2.6.1 or 2.6.2, build completes succesfully.

馃槸 Current Behavior

After updating to parcel 2.6.1 or 2.6.2, build will most of the time error with message:
Packaging index.[hash].js...
@parcel/compressor-raw: Cannot read properties of undefined (reading 'on')
On few occassions, re-running build will complete ok.

@devongovett
Copy link
Member

Maybe a weird dependency issue? Try deleting your lock file and node_modules and reinstalling.

@mischnic
Copy link
Member

mischnic commented Jul 3, 2022

If that doesn't help, please provide a reproduction.

2.6.0 working fine sounds like yet another regression of #8194 / #8235...

@aldrakos
Copy link
Author

aldrakos commented Jul 6, 2022

Can't really provide a reproduction as I'm not fully sure why it happens on our build. Attaching a screenshot of the error received. Not always the same file that throws the error and sometimes build succeeds. Tried deleting parcel cache, node modules, package-lock.json and reinstalling and trying again multiple times.

Screenshot 2022-07-06 175617

@EduMenges
Copy link

I just started a parcel project, and I'm having the same issue. I can't say the exact steps to reproduce, since, as it's happening to you, sometimes it builds, sometimes it gives me this error. However, I think it's not related to JS itself because it happens when I modify even a single letter on the main HTML file.

@mischnic
Copy link
Member

@EduMenges Are you also using Windows?

@EduMenges
Copy link

@mischnic Yes, I'm using Windows 10. I rolled back to 2.6.0 and no longer got this error.

@basitcodeenv
Copy link

I rollback parcel to version 2.6.0. I also got No Errors and it is working fine.

@aldrakos
Copy link
Author

Just to point out that I don't think it's Windows related: I've tried this on WSL2 / Ubuntu as well, deleting all node_modules and cache and running npm install and it's the same errors. I'll try on a unix based system too, but does not seem to be related.

@onionhammer
Copy link

onionhammer commented Jul 21, 2022

This is quite annoying.. and very inconsistent. I feel like when it starts to happen, if I just keep running it over and over (and getting this error over and over) it eventually fixes itself.

Running parcel 2.6.2 on Windows 10

@mischnic
Copy link
Member

As I've said: please say which OS you're using, and ideally share a reproduction

@onionhammer
Copy link

@mischnic apologies - Windows 10

@andywilsonuk
Copy link

Looking at the offending line:

stream.on('error', err => {
      reject(err);
    });

The error (I think) is that stream is undefined which comes from fs.createReadStream(filePath) in the same file but I've been unable to get an undefined out of createReadStream.

I would say it's about a 50% success rate of running the build with deleting the dist folder between executions and without any code modification each time.

Is there a way to tease out the file path?

Parcel 2.6.2, Node 16.3.0, Windows 11

@onionhammer
Copy link

@andywilsonuk you could try just sticking in some console.logs in the build, directly modify the file in your node modules

@mischnic
Copy link
Member

There's only a handful of places where hashStream is used: https://grep.app/search?q=hashStream&filter[repo][0]=parcel-bundler/parcel

When you edit node_modules to add logging, be sure to modify the lib directory of Parcel packages, not src

@andywilsonuk
Copy link

Right, I think it's this commit from last month. When I follow up the stack the error is coming from line 79 in that file. Here's an example of the writeStream properties just before line 79:

console: WriteStream {
  path: 'C:\\Code\\dist\\smartsound_WEAPONS_FLAMETHROWER_Long_Heavy_Single_01.ba2bc0e7.mp3.7204.o',
  flags: 'w',
  mode: 438,
  fd: null,
  start: undefined,
  pos: undefined,
  bytesWritten: 146827,
  closed: false,
  _writableState: WritableState {
    objectMode: false,
    highWaterMark: 16384,
    finalCalled: false,
    needDrain: false,
    ending: true,
    ended: true,
    finished: true,
    destroyed: true,
    decodeStrings: true,
    defaultEncoding: 'utf8',
    length: 0,
    writing: false,
    corked: 0,
    sync: false,
    bufferProcessing: false,
    onwrite: [Function: bound onwrite],
    writecb: null,
    writelen: 0,
    afterWriteTickInfo: null,
    buffered: [],
    bufferedIndex: 0,
    allBuffers: true,
    allNoop: true,
    pendingcb: 0,
    constructed: true,
    prefinished: true,
    errorEmitted: false,
    emitClose: true,
    autoDestroy: true,
    errored: null,
    closed: false,
    closeEmitted: false,
    [Symbol(kOnFinished)]: []
  },
  _events: [Object: null prototype] {
    error: [ [Function], [Function: onerror] ],
    close: [ [Function (anonymous)], [Function: onclose] ],
    end: [Function: onend],
    finish: [Function: onfinish]
  },
  _eventsCount: 4,
  _maxListeners: undefined,
  emit: [Function: emit],
  [Symbol(kFs)]: {
    appendFile: [Function: appendFile],
    appendFileSync: [Function: appendFileSync],
    access: [Function: access],
    accessSync: [Function: accessSync],
    chown: [Function (anonymous)],
    chownSync: [Function (anonymous)],
    chmod: [Function (anonymous)],
    chmodSync: [Function (anonymous)],
    close: [Function: close],
    closeSync: [Function: closeSync],
    copyFile: [Function: copyFile],
    copyFileSync: [Function: copyFileSync],
    createReadStream: [Function: createReadStream],
    createWriteStream: [Function: createWriteStream],
    exists: [Function: exists],
    existsSync: [Function: existsSync],
    fchown: [Function (anonymous)],
    fchownSync: [Function (anonymous)],
    fchmod: [Function (anonymous)],
    fchmodSync: [Function (anonymous)],
    fdatasync: [Function: fdatasync],
    fdatasyncSync: [Function: fdatasyncSync],
    fstat: [Function (anonymous)],
    fstatSync: [Function (anonymous)],
    fsync: [Function: fsync],
    fsyncSync: [Function: fsyncSync],
    ftruncate: [Function: ftruncate],
    ftruncateSync: [Function: ftruncateSync],
    futimes: [Function: futimes],
    futimesSync: [Function: futimesSync],
    lchown: [Function (anonymous)],
    lchownSync: [Function (anonymous)],
    lchmod: [Function (anonymous)],
    lchmodSync: [Function (anonymous)],
    link: [Function: link],
    linkSync: [Function: linkSync],
    lstat: [Function (anonymous)],
    lstatSync: [Function (anonymous)],
    lutimes: [Function: lutimes],
    lutimesSync: [Function: lutimesSync],
    mkdir: [Function: mkdir],
    mkdirSync: [Function: mkdirSync],
    mkdtemp: [Function: mkdtemp],
    mkdtempSync: [Function: mkdtempSync],
    open: [Function: open],
    openSync: [Function: openSync],
    opendir: [Function: opendir],
    opendirSync: [Function: opendirSync],
    readdir: [Function: readdir],
    readdirSync: [Function: readdirSync],
    read: [Function: read],
    readSync: [Function (anonymous)],
    readv: [Function: readv],
    readvSync: [Function: readvSync],
    readFile: [Function: readFile],
    readFileSync: [Function: readFileSync],
    readlink: [Function: readlink],
    readlinkSync: [Function: readlinkSync],
    realpath: [Function: realpath] { native: [Function (anonymous)] },
    realpathSync: [Function: realpathSync] { native: [Function (anonymous)] },
    rename: [Function (anonymous)],
    renameSync: [Function: renameSync],
    rm: [Function: rm],
    rmSync: [Function: rmSync],
    rmdir: [Function: rmdir],
    rmdirSync: [Function: rmdirSync],
    stat: [Function (anonymous)],
    statSync: [Function (anonymous)],
    symlink: [Function: symlink],
    symlinkSync: [Function: symlinkSync],
    truncate: [Function: truncate],
    truncateSync: [Function: truncateSync],
    unwatchFile: [Function: unwatchFile],
    unlink: [Function: unlink],
    unlinkSync: [Function: unlinkSync],
    utimes: [Function: utimes],
    utimesSync: [Function: utimesSync],
    watch: [Function: watch],
    watchFile: [Function: watchFile],
    writeFile: [Function: writeFile],
    writeFileSync: [Function: writeFileSync],
    write: [Function: write],
    writeSync: [Function: writeSync],
    writev: [Function: writev],
    writevSync: [Function: writevSync],
    Dir: [class Dir],
    Dirent: [class Dirent],
    Stats: [Function: Stats],
    ReadStream: [Function: ReadStream],
    WriteStream: [Function: WriteStream],
    FileReadStream: [Function: ReadStream],
    FileWriteStream: [Function: WriteStream],
    _toUnixTimestamp: [Function: toUnixTimestamp],
    F_OK: 0,
    R_OK: 4,
    W_OK: 2,
    X_OK: 1,
    constants: [Object: null prototype] {
      UV_FS_SYMLINK_DIR: 1,
      UV_FS_SYMLINK_JUNCTION: 2,
      O_RDONLY: 0,
      O_WRONLY: 1,
      O_RDWR: 2,
      UV_DIRENT_UNKNOWN: 0,
      UV_DIRENT_FILE: 1,
      UV_DIRENT_DIR: 2,
      UV_DIRENT_LINK: 3,
      UV_DIRENT_FIFO: 4,
      UV_DIRENT_SOCKET: 5,
      UV_DIRENT_CHAR: 6,
      UV_DIRENT_BLOCK: 7,
      S_IFMT: 61440,
      S_IFREG: 32768,
      S_IFDIR: 16384,
      S_IFCHR: 8192,
      S_IFLNK: 40960,
      O_CREAT: 256,
      O_EXCL: 1024,
      UV_FS_O_FILEMAP: 536870912,
      O_TRUNC: 512,
      O_APPEND: 8,
      F_OK: 0,
      R_OK: 4,
      W_OK: 2,
      X_OK: 1,
      UV_FS_COPYFILE_EXCL: 1,
      COPYFILE_EXCL: 1,
      UV_FS_COPYFILE_FICLONE: 2,
      COPYFILE_FICLONE: 2,
      UV_FS_COPYFILE_FICLONE_FORCE: 4,
      COPYFILE_FICLONE_FORCE: 4
    },
    promises: {
      access: [AsyncFunction: access],
      copyFile: [AsyncFunction: copyFile],
      open: [AsyncFunction: open],
      opendir: [Function: opendir],
      rename: [AsyncFunction: rename],
      truncate: [AsyncFunction: truncate],
      rm: [AsyncFunction: rm],
      rmdir: [AsyncFunction: rmdir],
      mkdir: [AsyncFunction: mkdir],
      readdir: [AsyncFunction: readdir],
      readlink: [AsyncFunction: readlink],
      symlink: [AsyncFunction: symlink],
      lstat: [AsyncFunction: lstat],
      stat: [AsyncFunction: stat],
      link: [AsyncFunction: link],
      unlink: [AsyncFunction: unlink],
      chmod: [AsyncFunction: chmod],
      lchmod: [AsyncFunction: lchmod],

It isn't always the same file but they it seems to always error on an un-optimised mp3 file > 20KB.

@mischnic
Copy link
Member

If it's line 79, then #8337 hopefully fixes it.

@mewhit
Copy link

mewhit commented Aug 23, 2022

Its fixed into 2.7.0 or not ?

@andywilsonuk
Copy link

I haven't seen any problems building after upgrading to 2.7.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants