AssetGraph: assert fails .type is 'asset' instead of 'asset_group'
See original GitHub issue🐛 bug report
When building/watching, I often get this crash
🚨 Build failed.
Error: The expression evaluated to a falsy value:
(0, assert().default)(n.type === 'asset_group')
AssertionError [ERR_ASSERTION]: The expression evaluated to a falsy value:
(0, _assert().default)(n.type === 'asset_group')
at AssetGraph.removeNode (node_modules/@parcel/core/lib/AssetGraph.js:214:31)
at AssetGraph.removeEdge (node_modules/@parcel/core/lib/Graph.js:248:12)
at AssetGraph.removeNode (node_modules/@parcel/core/lib/Graph.js:212:14)
at AssetGraph.removeNode (node_modules/@parcel/core/lib/AssetGraph.js:219:18)
at AssetGraph.removeEdge (node_modules/@parcel/core/lib/Graph.js:248:12)
at AssetGraph.removeNode (node_modules/@parcel/core/lib/Graph.js:212:14)
at AssetGraph.removeNode (node_modules/@parcel/core/lib/AssetGraph.js:219:18)
at AssetGraph.removeEdge (node_modules/@parcel/core/lib/Graph.js:248:12)
(when inspecting the .type, we see it’s a asset instead of asset_group).
It probably has something to do with my custom transformer: it makes 1x/2x/3x assets for require('asset:/myFile.png?size=100x100') by exposing these as extra parts in the transform step:
async transform({asset, config, options}) {
if (!asset.query.size) {
// probably the variant!
asset.isIsolated = true;
return [asset];
}
let code = 'module.exports = {\n';
const parts = [];
// ...
for (variant of ["3x","2x","1x"]) {
const result = await imagePipeline.clone().toBuffer();
const uniqueKey = asset.id+'@'+variant;
asset.addDependency({
moduleSpecifier: uniqueKey,
});
parts.push({
type: 'png',
pipeline: 'asset', // ??
uniqueKey,
content: result,
isIsolated: true,
});
code += JSON.stringify(variant) + ": require(" + JSON.stringify(uniqueKey) + "),\n";
});
code += '}';
asset.type = 'js';
asset.setCode(code);
return [asset, ...parts];
}
Note: re-inserting the parts into the same asset: “pipeline” feels rather clunky (might be the source if the issue?), but if I don’t do it I get:
No transformers found for assets/myImage.png.
🎛 Configuration (.babelrc, package.json, cli command)
const parcel = new Parcel({
entries: "index.html",
distDir: 'built/',
config: require.resolve("./.parcelrc"),
mode: "development",
contentHash: true,
});
await parcel.watch((e) => {
console.log("built! ", e);
})
{
"extends": "@parcel/config-default",
"transformers": {
"asset:*": ["parcel-transformer-my-asset"]
}
}
Also, using PARCEL_WORKER_BACKEND=process env.
💻 Code Sample
I can try to extract the crash case on request, but it’s quite some work!
🌍 Your Environment
| Software | Version(s) |
|---|---|
| Parcel | 2.0.0-nightly.462 |
| Node | node-v14.15.1-linux-x64 |
| npm/Yarn | yarn 1.22.4 |
| Operating System | linux |
Issue Analytics
- State:
- Created 3 years ago
- Reactions:2
- Comments:6 (5 by maintainers)
Top Results From Across the Web
Introduction | Asset Graph | 1.7.2-preview - Unity - Manual
When an error occurs in AssetGraph, a notification appears in the Asset Log. ... Split By Filter allows you to categorize assets based...
Read more >Reg : Assertion Failed ( Assert condition was violated )
Hi genus, I try to display the ASSET ( T.Code : AS03 ) . while click display , its going to dump. i...
Read more >assetgraph - npm
An auto discovery dependency graph based optimization framework for web pages and applications. Latest version: 7.10.0, last published: 2 ...
Read more >Using the New Asset Bundle Browser & Graph Tool - YouTube
Enjoy a preview of new features that make working with dynamically loaded content simple and efficient, while drastically reducing ...
Read more >Asset false statement to check if displayed - Stack Overflow
Asserting an element isn't present doesn't really work in selenium, you usually get an exception because it's trying to interact with an ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I edited the comment last night saying that upgrading to
2.0.0-nightly.540fixed the problem. So I think everything is all good?This should have been fixed by https://github.com/parcel-bundler/parcel/pull/5522