Closed peterbe closed 4 years ago
@escattone Can you help figure out what's wrong? Using careful cut-and-rerun, I've figured out that if you remove
<p>{{page("/en-US/docs/Web/API/MediaSessionAction", "Syntax")}}</p>
then it works. So there's something going haywire inside that macros.
If you put a console.log
in src/api/wiki.js
:
//
async page(path, section, revision, show, heading) {
+ console.log({path, section, revision, show, heading});
// Adjusts the visibility and heading levels of the specified HTML.
...then your stdout goes nuts. Clearly there's some sort of infinite loop recursion going on.
I think what would be REALLY worthwhile and interesting is to first write some new code that counts the recursion depth and if it goes over a certain number, throws. I'd much rather get thrown errors than OOM crashes.
Or, perhaps instead of a counter, we use a Set
to see which prerequisites we've gone done into and if that repeats, throw an error.
Oh I see. content/files/en-us/web/api/mediasessionactiondetails/index.html contains:
<p>{{page("/en-US/docs/Web/API/MediaSessionAction", "Syntax")}}</p>
and content/files/en-us/web/api/mediasessionaction/index.html contains:
<p>{{page("/en-US/docs/Web/API/MediaSessionActionDetails", "Examples")}}</p>
The reason it didn't fail in the WIki was presumably because it's able to re-use existing rendered HTML instead of our Yari JIT builder which will dig deep into every sub-rendering on the fly.
So, basically, how do we guard against such easy mistakes of authors creating an infinite loop?
It's probably happening in web/api/rtcdtmftonechangeevent
somewhere too.
It's getting stuck somewhere there too. And those pages aren't using the {{page(...)}}
macro.
I think this page is another example: https://github.com/mdn/content/blob/0579292823efff25be2a7ec86e16adb63bc52e90/files/en-us/web/api/rtcerror/index.html#L54
Note-to-selfs; http://localhost:3000/en-US/docs/Web/HTML/Element/input/tel uses the {{page()}}
macro a lot. In good and sane ways. It's benefits from the memoization but if you disable memoization it should just get slower, not break.
The file that triggers the OOM crash is: https://github.com/mdn/content/blob/e7c50f5d2383924101236cbcedaf218648f311b9/files/en-us/web/api/mediasession/setactionhandler/index.html
To reproduce, simply open http://localhost:3000/en-US/docs/Web/API/MediaSession/setActionHandler in
yarn dev
After a long time, you'll get something like this: