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.
Description
When testing the self hosted lessons I was seeing
internal server error
when I initially loaded into js4/css lesson page and then clicked the link to the part 1 or 3 lessons and was also seeing this message in the console.log:And our sentry.io log picked up some nice additional details like the route it was happening on:
The Problem
I was able to quickly guess it was connected to the embedded
codepens
since the only route the error was appearing on was thecss
page which is the only lesson with codepens.We were using the recommended HTML embedding style that relies on a script tag to manipulate the dom. React wasn't liking some 3rd party tool stepping on its toes though and was balking about it when it tried to remove nodes that the script had already removed.
Solution
Convert from embedding the script tag to using the
iframe
element embed option. To make it a little more reusable I created a separate<CodePen />
component that is hardcoded to the c0d3pen user account and will allow us to make our lessons slightly more maintainable.I was tempted to reach for an already built off the shelf component from this mdx-embedded package but in the end decided to roll my own for a little more flexibility in the future if we want to change things and not unnecessarily add an additional dependency
The working preview branch link: https://c0d3-app-mw3rh6zaq-c0d3.vercel.app/curriculum/js4/css
Side note
This should be the last roadblock to going live with the self hosted lessons which has me really excited !