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

Site is broken b/c of JS stack overflow #33

Closed
armanbilge opened this issue Oct 28, 2021 · 5 comments · Fixed by #45
Closed

Site is broken b/c of JS stack overflow #33

armanbilge opened this issue Oct 28, 2021 · 5 comments · Fixed by #45
Labels
bug Something isn't working documentation Improvements or additions to documentation

Comments

@armanbilge
Copy link
Member

armanbilge commented Oct 28, 2021

As reported by discord friends.

Linking to:

@armanbilge armanbilge added bug Something isn't working documentation Improvements or additions to documentation labels Oct 28, 2021
@armanbilge
Copy link
Member Author

armanbilge commented Nov 2, 2021

Some progress on this: I suspect the problem comes from the README.md.js file, where mdoc_js_run0 is defined:
https://http4s.github.io/http4s-dom/README.md.js
https://raw.githubusercontent.com/http4s/http4s-dom/d7a56a67ddca8b67b2e31da74d96c567b46ad898/README.md.js

Specifically, I think the maximum call stack size is being exceeded while running that file, causing it to fail, and that variable to be undefined.

To test this, I tried running that file with Node.js:

node --stack_size=500 README.md.js
vm.js:74
      super(code,
      ^

RangeError: Maximum call stack size exceeded
    at new Script (vm.js:74:7)
    at createScript (vm.js:246:10)
    at Object.runInThisContext (vm.js:298:10)
    at Module._compile (internal/modules/cjs/loader.js:657:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:236:19)

Increasing the stack size to 600 enables the file to load without problem.

So, the stack size on iOS Safari must be smaller than 600 and generally smaller than other browsers.

The remaining question is, which part of the Scala.js/mdoc.js/CE3/fs2/http4s stack is specifically to blame for this 😉

@armanbilge
Copy link
Member Author

I wouldn't be shocked if MimeDB is to blame for this too ...

@armanbilge armanbilge changed the title Fix site on iOS mobile Fix site on ~iOS~ mobile Nov 21, 2021
@armanbilge armanbilge changed the title Fix site on ~iOS~ mobile Fix site on mobile Nov 21, 2021
@armanbilge armanbilge changed the title Fix site on mobile mdoc.js on site causes stack overflow Nov 25, 2021
@armanbilge
Copy link
Member Author

And here's a report from Firefox on macOS desktop ...
unknown

@armanbilge armanbilge changed the title mdoc.js on site causes stack overflow Site is broken b/c of JS stack overflow Nov 25, 2021
@armanbilge
Copy link
Member Author

Here's another interesting twist: if the README.md.js is generated with fastOptJS instead of fullOptJS then I can lower the stack size to much more reasonable numbers without problem.

node --stack_size=80 mdocs/target/mdoc/README.md.js

So, the problem is specific to fullOptJS.

Next bit of trickyness, is to tease apart SJS full optimization phase from the Google Closure Compiler phase.

@armanbilge
Copy link
Member Author

Next bit of trickyness, is to tease apart SJS full optimization phase from the Google Closure Compiler phase.

Following up on this, by locally publishing mdoc with https://github.com/scalameta/mdoc/blob/6a5be8cbde534662b27f1b68d2e12384a31216c9/mdoc-js/src/main/scala/mdoc/modifiers/JsModifier.scala#L80 adjusted I was able to do fullOptJS but disable GCC. Well, turns out that it is the GCC phase.

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

Successfully merging a pull request may close this issue.

1 participant