pixiebrix-extension icon indicating copy to clipboard operation
pixiebrix-extension copied to clipboard

RENDER_NUNJUCKS not available within 3 seconds

Open twschiller opened this issue 1 year ago • 15 comments

Describe the bug

  • RENDER_NUNJUCKS not available within 3 seconds

To Reproduce

The error is intermittent. What @brittanyjoiner15 is seeing is most likely that either: 1) a selection watch trigger is failing, or 2) a page load trigger (e.g., to fetch announcements) is failing on some pages

Likely steps to reproduce:

  • Add a page load trigger with no debounce
  • Configure the trigger to show an error on failure
  • Add a brick that uses a nunjucks template. E.g., the identity brick with {{ @input.url }}
  • Browse the web and wait for the error to pop up

Actual behavior

  • A mod fails with error "RENDER_NUNJUCKS not available within 3 seconds"
  • Behavior depends on what the triggers error handler is set to (i.e., whether or not an error toast will be shown)

Discussion

  • RENDER_NUNJUCKS is handled by the sandbox injected into the page: https://github.com/pixiebrix/pixiebrix-extension/blob/6e2f02e1d6f2c6fa8bf8f96be25278bc4586bbe5/src/sandbox/messenger/api.ts#L62-L62
  • In MV3, all nunjucks evaluation is run via the Sandbox. (In MV2, you have to toggle it on. Javascript brick is always run in the sandbox though)
  • To diagnose the error, you need to figure out whether that error would be thrown if:
    • Is the sandbox not getting added to the page properly? Or,
    • Is the sandbox added, but then getting removed?
    • Is the sandbox on the page, but it's not responding in time (e.g., b/c it's processing another message)?

Potential Solution

  • Add automatic retries when renderNunjucks fails
  • Advice users to refresh the page if renderNunjucks fails 4 times
  • Similar to: https://github.com/pixiebrix/pixiebrix-extension/pull/8474

twschiller avatar Apr 10 '24 23:04 twschiller