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
coffee -c fails on moderately large .coffee files in v2.6.0 (worked in 2.5 and earlier) #5378
Comments
cc @edemaine @helixbass I’d guess that this was caused by one of the three PRs in #5374. @rodw if you have time, you can narrow things down to the commit where the issue was introduced by checking out the CoffeeScript repo, building locally, and stepping back commit by commit until the problem goes away (which should be the commit with 2.5.1, if not somewhere between that and 2.6.0). There are only ten commits between the versions, though several of them can be ignored as they’re changes to documentation or CI. |
@rodw I tried your test on my machine. Under 2.5.1 the file with 6969 lines compiled for me in 9 seconds. Under 2.6.0 it also throws with I went back commit by commit on I tried compiling the test file with I wrote a test for this, along the lines of the reproduction steps, but it tripled the time it took for the tests to run so I removed it. It we can think of a test that can validate that this doesn’t break in the future, and takes < 200 ms or so on its own to run, that would be good to add. |
@GeoffreyBooth Thanks for tracking this down, and fixing it! The new code looks good. Alternatively, I think Apologies for introducing the performance bug. I forgot (having learned only recently) that I also couldn't find an example for testing that has a lot of top-level lines and isn't really slow to compile. 🙁 |
I think the reason this probably didn’t affect more people is that this only happens when bare mode is not used. |
I finally got around to testing my app with this fix and everything is working fine under Coffee 2.6.1. Thanks to @GeoffreyBooth et al for the quick fix. Looking forward to taking advantage of the 2.6 features! |
Compilation (via
coffee -c
) in v2.6.0 seems to fail on large(-ish) .coffee files that worked in v2.5.1 and previous releases. (And that are well within a range one could reasonably expect to work IMO.)I have an electron app implemented in CoffeeScript. As part of my build process I concatenate a large number of .coffee files into a single renderer.coffee, and then compile with
coffee -c renderer.coffee
to generaterenderer.js
, which is the file loaded by my root HTML page in electron.This process has worked well for a couple of years at least. However when I attempted to upgrade to CoffeeScript v2.6 I found that
coffee -c renderer.coffee
is now failing with an error like the followingI believe I've discovered a relatively simple example that reproduces this problem at just under 7000 lines.
Take the following script:
Running that program (e.g.,
coffee large-coffee-generator.coffee > foo.coffee
) will generate a file that looks something like:where that last line is repeated
max
times for a total ofmax + 1
lines.Now try to compile that output via
coffee -c foo.coffee
With CoffeeScript v2.5.1 this works (somewhat slowly) with
max
values of 40,000 or more.With CoffeeScript v2.6.0 this works for
max = 6968
- running in about 8s in on my MacBook Pro laptop - but fails formax = 6969
. I.e. it starts to fail with a "Maximum call stack size exceeded" error at precisely 6970 lines.For context:
I'm running this on a modernish MacBook Pro: 2 GHz Quad-Core Intel Core i5 with 32 GB RAM
I'm using Node v14.16.0 (the latest stable release)
I'm using CoffeeScript v2.6.0 (the latest stable release)
The text was updated successfully, but these errors were encountered: