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

Flatten sourcemaps lazily when serving #68

Open
Rich-Harris opened this issue May 7, 2015 · 17 comments
Open

Flatten sourcemaps lazily when serving #68

Rich-Harris opened this issue May 7, 2015 · 17 comments

Comments

@Rich-Harris
Copy link
Contributor

As mentioned here, it'd be great if the sourcemap flattening process happened in the background when gobble is serving. Rather than proactively searching all the built files to see if they have sourcemap chains that need flattening, gobble could wait for a request from the browser and do it then, which would provide a nice boost to perceived speed with sacrificing any of that sourcemappy goodness.

For gobble watch and gobble build it would still need to be proactive though.

@martypdx
Copy link

martypdx commented May 7, 2015

I just upgraded what I could figure out to upgrade in the ractive project with the hopes of being able to use source maps again. Seems to be working better, though occasionally still end up looking at:


// Please wait a bit.
// Compiled script is not shown while source map is being loaded!

if debugger breaks early in the loading. I bring this up because I don't know if this would be a more regular thing if they were loaded lazily, or whether this would solve the issue.

EDIT: Sourcemaps still don't have any legs. They work for about 5-10 minutes, then nothing but above. But then if fiddle with new browser tab or gobble restart, works again for a little while.

@Rich-Harris
Copy link
Contributor Author

I suppose you'd be more likely to hit 'please wait a bit', but the total time (from invalidation to sourcemapped debugging) would be the same or less, so I reckon it's a net plus.

They work for about 5-10 minutes, then nothing but above

That's weird, even by the Twilight Zone-esque standards of this stuff. It might possibly because of something else I've noticed (or rather, my long-suffering colleagues have complained about) - sometimes if you reload the page while a build is happening, you get half a build, when you should get the 'gobbling' page. Haven't had a chance to try and reliably reproduce it though. Does that sound plausible?

@martypdx
Copy link

martypdx commented May 7, 2015

No, don't get a gobble page, everything builds and runs fine, it just doesn't load the sourcemaps.

Easiest way is to turn Pause on all Exceptions on, then run a specific unit test in ractive where there's an error in the called ractive code.

I suspect it may have to do with chrome too and how it caches things.

@martypdx
Copy link

martypdx commented May 7, 2015

This doesn't seem good:

image

@Rich-Harris
Copy link
Contributor Author

Wow, no that doesn't look good at all. Is that something that only happens after the task has been running a while? How big is the .map file?

@martypdx
Copy link

martypdx commented May 7, 2015

So this is one that actually "worked':

image

Let me see if I can get it not working for size compare.

@martypdx
Copy link

martypdx commented May 7, 2015

Here's one where it has stalled:

image

then after stepping through some breakpoints when it's complete it shows as downloaded:

image

@martypdx
Copy link

martypdx commented May 7, 2015

oh, take a look at the trailing "livereload" requests. They don't exist on the one that works

@Rich-Harris
Copy link
Contributor Author

Only 2.1 minutes? Don't know what you're complaining about...

Are there steps you can take to reliably get it into a broken state? Or is it just a case of continually changing source files until something snaps?

@martypdx
Copy link

martypdx commented May 7, 2015

Only 2.1 minutes? Don't know what you're complaining about...

well that's my time hanging out with debugger paused. so it gives me opportunity to get coffee or have smoke in the mean time 😉

Are there steps you can take to reliably get it into a broken state? Or is it just a case of continually changing source files until something snaps?

usually I'm running a single test in single test file - so I'm repetitively doing that. Once it's borked, I have to create a new tab in chrome (or turn off source maps and use ractive-legacy directly)

@martypdx
Copy link

martypdx commented May 8, 2015

oh, maybe we're hitting chrome's 6 max connections. how are you serving the static files?

@Rich-Harris
Copy link
Contributor Author

Crudely. Should probably be streaming, for one thing. I'd assumed that there wasn't a problem with max connections though, because I'm sure it's served more than 6 files simultaneously in the past - I could be wrong though

@martypdx
Copy link

martypdx commented May 8, 2015

I'm down with bare metal http. :) Just an idea that maybe there not being "close" somehow or otherwise hand-shaking with chrome on this - because it's EXACTLY the seventh thing (not counting the already served .html file).

Let me try removing the simulant ref and try a test page that doesn't need it.

@Rich-Harris
Copy link
Contributor Author

I'm experiencing the same thing. So Chrome can't ingest a sourcemap while the debugger is paused? That seems totally nuts. Anyway, I've implemented lazy sourcemaps (#71) and it seems to be working - doesn't do anything for the debugger issue though.

@martypdx
Copy link

martypdx commented May 8, 2015

Would it make more sense to not combine the sourcemaps into one uber file but rather serve them independently?

@Rich-Harris
Copy link
Contributor Author

When I first started tinkering around with this stuff I assumed that browsers would be smart enough to handle multiple levels of sourcemaps, but they're not - if foo.js has a foo.js.map sourcemap that lists bar.js as a source, the browser will stop at bar.js even if there's a bar.js.map file that lists baz.js and so on. Which is why sorcery exists - you have to flatten all the chains leading up to foo.js into a single foo.js.map. One .js/.css file, one map. No way around it as far as I can tell.

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

2 participants