Set up Markdown handling exactly once #127
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
@confused-Techie's addition of paranoid logging paid off. One of the instances went sideways again and now we've got a paper trail:
When we render a package README, we do some custom processing of URLs because we want images and links to point to the right places instead of 404ing. In some cases, this custom processing needs access to metadata about the current package, so we were adding new callbacks inside of the
prepareForDetail
function inutils.js
. But each time we added a new handler, we were calling the old one at the end… so we were building up an onion skin of link handlers.Eventually, after an instance handles one too many requests to view a package detail page, an attempt to rewrite a single image URL fails with
Maximum call stack size exceeded
.The fix here is to ensure that we add our custom callbacks only once. To get around the issue of needing access to package information, we can declare
let currentPackage
in the top-level scope, then assign it to our newpack
object only for as long as needed to generate README markup. Definitely a hack, but right now I don't care.