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

Maximum call stack size exceeded after fullOptJS #119

Closed
armanbilge opened this issue Mar 22, 2022 · 4 comments · Fixed by http4s/http4s#6211
Closed

Maximum call stack size exceeded after fullOptJS #119

armanbilge opened this issue Mar 22, 2022 · 4 comments · Fixed by http4s/http4s#6211
Labels
bug Something isn't working

Comments

@armanbilge
Copy link
Member

armanbilge commented Mar 22, 2022

Reported by @buntec:

I now run into a “maximum call stack size exceeded” exception in one of the projects at work using ff4s when making a simple GET request using ‘client.expect’. The source map points to line 255 in ‘MediaType.scala’, which looks innocuous to me. According to the call stack this seems to happen during entity decoding. I’m using 0.23.11. Strangely enough, this only occurs in the fully optimized js bundle; not during development when using fastOpt.

This sounds a lot like:

If we look at the reported line:

object MediaType extends MimeDB {

https://github.com/http4s/http4s/blob/v0.23.11/core/shared/src/main/scala/org/http4s/MediaType.scala#L255

It leads us to our old friend:

The current workaround is to disable GCC in fullOptJS with:

scalaJSLinkerConfig ~= { _.withClosureCompilerIfAvailable(false) }

I would like to explore alternative minimizers to GCC such as ESBuild:
https://esbuild.github.io/api/#minify

I also have a plan to fix #30 in http4s/http4s#5273. It is quite a bit of work to do binary-compatibly, but feasible I think.

@armanbilge armanbilge added the bug Something isn't working label Mar 22, 2022
@armanbilge
Copy link
Member Author

I would like to explore alternative minimizers to GCC such as ESBuild

Note: minifiers are not the same as optimizers. The ESBuild minifier reduces the 12 mb (!!) fetch demo to 6 mb. Meanwhile the closure compiler reduces it to 2 mb, albeit introducing the stack overflow problem. So I think the only way forward is to fix this in http4s core.

@armanbilge
Copy link
Member Author

armanbilge commented Mar 27, 2022

Update: it seems the correct way to disable the closure compiler is like this. H/t Christoph.

scalaJSLinkerConfig ~= { _.withClosureCompiler(false) }

@armanbilge
Copy link
Member Author

I've PRed a fix upstream in http4s/http4s#6211. Please try the snapshot (instructions in PR :)

@armanbilge
Copy link
Member Author

I can confirm the PR snapshot fixes the similar problem I experienced in #33 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant