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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssertionError: (0, _assert().default)(node.type === 'file') #8477

Closed
mischnic opened this issue Sep 15, 2022 · 1 comment · Fixed by #9264
Closed

AssertionError: (0, _assert().default)(node.type === 'file') #8477

mischnic opened this issue Sep 15, 2022 · 1 comment · Fixed by #9264

Comments

@mischnic
Copy link
Member

mischnic commented Sep 15, 2022

🐛 bug report

A build using the glob resolver fails with an assertion error when reusing the cache.

Happens only when the modified file isn't actually part of the build

🤔 Expected Behavior

Works

😯 Current Behavior

AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:

  (0, _assert().default)(node.type === 'file')

    at /node_modules/@parcel/core/lib/RequestTracker.js:519:35
    at Array.map (<anonymous>)
    at RequestGraph.respondToFSEvents (/node_modules/@parcel/core/lib/RequestTracker.js:517:117)
    at loadRequestGraph (/node_modules/@parcel/core/lib/RequestTracker.js:864:18)
    at async Function.init (/node_modules/@parcel/core/lib/RequestTracker.js:821:17)
    at async Parcel._init (/node_modules/@parcel/core/lib/Parcel.js:256:28)
    at async Parcel.run (/node_modules/@parcel/core/lib/Parcel.js:273:7)
    at async run (/node_modules/parcel/lib/cli.js:376:7) {
  generatedMessage: true,
  code: 'ERR_ASSERTION',
  actual: false,
  expected: true,
  operator: '=='
}

💻 Code Sample

https:/mischnic/parcel-issue-8477

🌍 Your Environment

Software Version(s)
Parcel 2.7.0
Operating System macOS
@marcins
Copy link
Contributor

marcins commented Nov 14, 2022

I managed to locally work around this problem by changing this:

let above = this.getNodeIdsConnectedTo(
fileNameNodeId,
requestGraphEdgeTypes.invalidated_by_create_above,
).map(nodeId => {
let node = nullthrows(this.getNode(nodeId));
invariant(node.type === 'file');
return node;
});

to something like:

           let above = this.getNodeIdsConnectedTo(
            fileNameNodeId,
            requestGraphEdgeTypes.invalidated_by_create_above,
          )
            .map(nodeId => nullthrows(this.getNode(nodeId)))
            .filter(node => node.type === 'file');

.. since just below glob types seem to be processed separately, and checks if they're connected:

for (let globeNodeId of this.globNodeIds) {
let globNode = this.getNode(globeNodeId);
invariant(globNode && globNode.type === 'glob');

I haven't checked if this passes tests / is valid, but seems to "work for me".

Just putting it down here, if I get a chance I'll try it in the codebase and see how tests go.

@github-actions github-actions bot added the Stale Inactive issues label May 13, 2023
@mischnic mischnic removed the Stale Inactive issues label May 13, 2023
@parcel-bundler parcel-bundler deleted a comment from github-actions bot May 13, 2023
marcins added a commit that referenced this issue Sep 22, 2023
This fixes #8477.

I wasn't able to get a reliable repro in a test for this, but I have
previously manually applied this patch in a large codebase where we saw
this issue and it resolved it.
devongovett pushed a commit that referenced this issue Oct 3, 2023
This fixes #8477.

I wasn't able to get a reliable repro in a test for this, but I have
previously manually applied this patch in a large codebase where we saw
this issue and it resolved it.

Co-authored-by: mattcompiles <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants