Parcel: `parcel serve` throws an error trying to read cache blob

Created on 18 Apr 2020  ยท  18Comments  ยท  Source: parcel-bundler/parcel

๐Ÿ› bug report

parcel serve after an indeterminate amount of time (sometimes immediately) will throw an error attempting to read a .blob file in the .parcel-cache directory.

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

No babel config.

package.json as follows:

{
  "name": "web",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "browserslist": [
    "Chrome 78"
  ],
  "scripts": {
    "start": "parcel serve src/index.html",
    "lint": "eslint \"**/*.jsx\"",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "babel-eslint": "^10.1.0",
    "eslint": "^6.1.0",
    "eslint-config-airbnb": "^18.0.1",
    "eslint-plugin-import": "^2.20.2",
    "eslint-plugin-jsx-a11y": "^6.2.3",
    "eslint-plugin-react": "^7.19.0",
    "eslint-plugin-react-hooks": "^3.0.0",
    "parcel": "^2.0.0-nightly.225"
  },
  "dependencies": {
    "@reduxjs/toolkit": "^1.2.3",
    "@xstate/react": "^0.8.1",
    "faker": "^4.1.0",
    "feather-icons": "^4.26.0",
    "firebase": "^7.14.0",
    "fuse.js": "^5.1.0",
    "polished": "^3.5.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-redux": "^7.1.3",
    "react-router-dom": "^5.1.2",
    "redux": "^4.0.5",
    "redux-logger": "^3.0.6",
    "redux-persist": "^6.0.0",
    "styled-components": "^5.0.1",
    "xstate": "^4.8.0"
  }
}

๐Ÿค” Expected Behavior

parcel serve to read the cache blob correctly

๐Ÿ˜ฏ Current Behavior

> parcel serve src/index.html

โ„น๏ธ Server running at http://localhost:1234
โ  Optimizing web.[hash].js...
events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open '.parcel-cache/50/e8902ca6a84c52e55907a97e40c90b.blob'
Emitted 'error' event on ReadStream instance at:
    at internal/fs/streams.js:163:14
    at FSReqCallback.oncomplete (fs.js:154:23) {
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '.parcel-cache/50/e8902ca6a84c52e55907a97e40c90b.blob'
}

I can see that the blob file does in-fact exist on disk once I see the error, but I can't verify if it's there before.

๐Ÿ”ฆ Context

Mostly it's just an inconvenience.

I've found that:

  • Re-running my start script tends to fix it, though not every time.
  • Removing the .parcel-cache directory appears to be a consistent fix.
  • Running serve --no-cache doesn't remedy the problem.

๐ŸŒ Your Environment

| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 2.0.0-alpha.3.2 (also occurs with 2.0.0-nightly.225)
| Node | 13.8.0
| npm | 6.13.6
| Operating System | macOS Mojave 10.14.4

Bug Confirmed Bug โœจ Parcel 2 ๐Ÿ’ฐ Cache

Most helpful comment

This happens to me too, on OS X.

All 18 comments

The error i have is related to this one so i'm posting here instead of making a new issue.
But this one is consistent and i can't manage to make a bundle work at all even after deleting the cache or restarting the script.

Even though parcel throws this error, it's still running and if i just edit foo.ts, Parcel then throws the error @sdjnes sent.

foo.ts

console.log('foo')

package.json

{
  "name": "foo",
  "version": "1.0.0",
  "license": "MIT",
  "devDependencies": {
    "parcel": "^2.0.0-nightly.227"
  },
  "scripts": {
    "dev": "parcel src/index.ts"
  }
}
$ parcel src/index.ts
โ„น Server running at http://localhost:1234   
ร— Build failed.
Error: EPERM: operation not permitted, rename 
'C:UsersBanouDesktopfoo.parcel-cache49ae1c9e65887f82dbab08fccc6d0bc6.blob.25316.1.4' -> 'C:UsersBanouDesktopfoo.parcel-cache49ae1c9e65887f82dbab08fccc6d0bc6.blob'
Error: EPERM: operation not permitted, rename 
'C:\Users\Banou\Desktop\foo\.parcel-cache\49\ae1c9e65887f82dbab08fccc6d0bc6.blob.25316.1.4' 
-> 'C:\Users\Banou\Desktop\foo\.parcel-cache\49\ae1c9e65887f82dbab08fccc6d0bc6.blob'

@wbinnssmith implemented that atomic write mechanism.

Can confirm @Banou26 's issue. Deleting cache does not have an effect.

Gonna revert to parcel 2.0.0-nightly.118, which works.

npm run tsc && parcel src/index.html

โ„น Server running at http://localhost:1234
| Building _object-gopn-ext.js...
events.js:298
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open <my-path>\.parcel-cache\9a\e4977caeecbcb830a3662be71f824d.blob'
Emitted 'error' event on ReadStream instance at:
    at internal/fs/streams.js:163:14
    at FSReqCallback.oncomplete (fs.js:158:23) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: '<my-path>\\.parcel-cache\\9a\\e4977caeecbcb830a3662be71f824d.blob'
}

Can someone post a reproduction?

Literally the files i sent in my comment, https://github.com/Banou26/parcel-bug-4495

Windows 10, 1909
Node v13.9.0

This seems to cause a crash on Windows only (because of the FS behaves differently).

But I think this is not a cache problem but deeper: AssetGraphBuilder#queueRequest gets called two times for runtime assets (HMRRuntime.js in the example above - this is also why Building HMRRuntime.js... is printed twice to the console).
The requests are run in order, but when the second request starts, the first request result hasn't been written to cache yet. So they write to cache concurrently, here is a trace of the createWriteStream calls:

Bundling...
Building HMRRuntime.js...
Building HMRRuntime.js...
Transformation writeToCache 'packages/runtimes/hmr/src/HMRRuntime.js'
open .parcel-cache/1e/f1ea5d836316ed075e2ac4c31bf61d.blob
Transformation writeToCache 'packages/runtimes/hmr/src/HMRRuntime.js'
open .parcel-cache/1e/f1ea5d836316ed075e2ac4c31bf61d.blob
close .parcel-cache/1e/f1ea5d836316ed075e2ac4c31bf61d.blob
close .parcel-cache/1e/f1ea5d836316ed075e2ac4c31bf61d.blob
...

The calls where the asset is queued twice:

console: Trace: AssetGraphBuilder runRequest packages/runtimes/hmr/src/HMRRuntime.js
    at AssetGraphBuilder.queueRequest (packages/core/core/src/AssetGraphBuilder.js:298:13)
    at AssetGraphBuilder.processIncompleteAssetGraphNode (packages/core/core/src/AssetGraphBuilder.js:375:12)
    at AssetGraphBuilder.handleIncompleteNode (packages/core/core/src/AssetGraphBuilder.js:382:10)
    at AssetGraph.onIncompleteNode (packages/core/core/src/AssetGraphBuilder.js:125:38)
    at AssetGraph.markIncomplete (packages/core/core/src/AssetGraph.js:174:12)
    at AssetGraph.addNode (packages/core/core/src/AssetGraph.js:158:12)
    at AssetGraph.replaceNodesConnectedTo (packages/core/core/src/Graph.js:334:12)
    at reconcileNewRuntimes (packages/core/core/src/applyRuntimes.js:175:14)
    at applyRuntimes (packages/core/core/src/applyRuntimes.js:83:34)
    at BundlerRunner.bundle (packages/core/core/src/BundlerRunner.js:112:5)
console: Trace: AssetGraphBuilder runRequest packages/runtimes/hmr/src/HMRRuntime.js
    at AssetGraphBuilder.queueRequest (packages/core/core/src/AssetGraphBuilder.js:298:13)
    at AssetGraphBuilder.processIncompleteAssetGraphNode (packages/core/core/src/AssetGraphBuilder.js:375:12)
    at AssetGraphBuilder.build (packages/core/core/src/AssetGraphBuilder.js:229:14)
    at reconcileNewRuntimes (packages/core/core/src/applyRuntimes.js:184:11)
    at applyRuntimes (packages/core/core/src/applyRuntimes.js:83:28)
    at BundlerRunner.bundle (packages/core/core/src/BundlerRunner.js:112:5)
    at Parcel.build (packages/core/core/src/Parcel.js:264:25)
    at Parcel.startNextBuild (packages/core/core/src/Parcel.js:176:21)
    at PromiseQueue._runFn (packages/core/utils/src/PromiseQueue.js:84:7)
    at PromiseQueue._next (packages/core/utils/src/PromiseQueue.js:73:5)

cc @padmaia

This happens to me too, on OS X.

I run into the same issue on OS X (2.0.0-alpha.3.2).

I think mine is related to this one too, or is it another issue?

Node: v12.16.1
Parcel: ^2.0.0-alpha.3.2
OS: Windows 10

Running: parcel build ./src/roleta.js

@parcel/workers: ENOENT: no such file or directory, rename 'D:DEVroleta.parcel-cachee518c077fa3cde0c05fdc50e47c5833a.blob.12188.3.0' -> 'D:DEVroleta.parcel-cachee518c077fa3cde0c05fdc50e47c5833a.blob'
Error: ENOENT: no such file or directory, rename 'D:\DEV\roleta\.parcel-cache\e5\18c077fa3cde0c05fdc50e47c5833a.blob.12188.3.0' -> 'D:\DEV\roleta\.parcel-cache\e5\18c077fa3cde0c05fdc50e47c5833a.blob'
    at Object.renameSync (fs.js:660:3)
    at WriteStream.<anonymous> (D:\DEV\roleta\node_modules\@parcel\fs\lib\NodeFS.js:74:42)
    at WriteStream.emit (events.js:311:20)
    at emitCloseNT (internal/streams/destroy.js:69:8)
    at processTicksAndRejections (internal/process/task_queues.js:83:21)
| Building styles.css...

and it keeps going forever...

You can see that the backslashes are removed.

Do folks mind confirming if this is resolved by #4625 (which has been merged and should be in a nightly shortly)?

@wbinnssmith i think it is not solved

https://github.com/parcel-bundler/parcel/runs/687497965

image

@robsontenorio It appears that benchmark runs following the merge of #4625 no longer produce the error above, such as in https://github.com/parcel-bundler/parcel/runs/687543724?check_suite_focus=true โ€” mind testing with @Banou26's reproduction?

That error also seems to depict #4614 โ€” renaming a temporary filepath โ€” not this issue.

Tried using my repro & parcel 2.0.0-nightly.270:

C:\Users\Banou\Desktop\parcel-bug-4495>yarn dev
yarn run v1.22.0
$ parcel src/index.ts
โ„น Server running at http://localhost:1234
/ Bundling...
events.js:292
      throw er; // Unhandled 'error' event
      ^

Error: ENOENT: no such file or directory, open 'C:\Users\Banou\Desktop\parcel-bug-4495\.parcel-cache\b1\e1ef6515ea7fae75fe80781c0daabb.blob'
Emitted 'error' event on ReadStream instance at:
    at internal/fs/streams.js:162:14
    at FSReqCallback.oncomplete (fs.js:163:23) {
  errno: -4058,
  code: 'ENOENT',
  syscall: 'open',
  path: 'C:\\Users\\Banou\\Desktop\\parcel-bug-4495\\.parcel-cache\\b1\\e1ef6515ea7fae75fe80781c0daabb.blob'
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Also found out that trying to run parcel while the port is already used result in an instant crash, now.

C:\Users\Banou\Desktop\parcel-bug-4495>yarn dev
yarn run v1.22.0
$ parcel src/index.ts
โš ๏ธ  Port 1234 could not be used.
error Command failed with exit code 3221225477.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@wbinnssmith 2.0.0-nightly.270 was avaliabe before your PR. Can't see next build

yarn add parcel@v2 --dev

image

Oh, oops ๐Ÿ˜ณ, gonna try again when the next nightly will be released then.

This should be available now in 2.0.0-nightly.273 ๐Ÿ˜„

Looks all good to me now ๐Ÿ‘

Was this page helpful?
0 / 5 - 0 ratings

Related issues

donaldallen picture donaldallen  ยท  3Comments

davidnagli picture davidnagli  ยท  3Comments

oliger picture oliger  ยท  3Comments

Niggler picture Niggler  ยท  3Comments

will-stone picture will-stone  ยท  3Comments