Rich-Harris / sorcery

Resolve a chain of sourcemaps back to the original source, like magic

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Warning: Cannot call method 'trace' of undefined

JohnLouderback opened this issue · comments

When running this syncronously:

var chain = sorcery.loadSync(temp + 'test.js');
chain.apply();

I get the error:

Warning: Cannot call method 'trace' of undefined

strangely, logging console.log(chain.__proto__) shows the trace is, in fact, a method of chain.

It's a method of Chain.prototype, but also a method of Node.prototype - internally, files are represented as 'nodes', and node.trace() is what chain.trace() delegates to. If a node finds a mapping to a 'parent' node (meaning closer to the original source), it traces that - so it sounds like what's happening is that we have a mapping with a source index of x, but node.sources[x] doesn't exist.

I've seen a similar error once or twice, but never at a moment when I've had time to stop what I'm doing and dig into it! Any chance you would be able to share a minimal reproduction of the bug, so I can investigate? Thanks

Sure thing. Here's a minimal and realworld example

https://www.dropbox.com/s/wrh0yhm1f537wj8/sorcery-debug.zip?dl=0

Awesome, thank you. Will look into this as soon as time allows

Hey Rich,

Any news on this?

@JohnLouderback Sorry for the crazy delay on this, been up to the gills lately. The repro you provided was very helpful in getting to the bottom of this - the fix is in, just released it as 0.6.2.

Just wanted to swing by and say "Thanks!". This works like a charm. I'm extremely grateful. Awesome tool.