mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
28 stars 16 forks source link

Zendesk code: TypeError: null is not an object (evaluating 'e.contentDocument') #4371

Open sentry-io[bot] opened 4 years ago

sentry-io[bot] commented 4 years ago

Sentry Issue: MICROMASTERS-2H5

TypeError: null is not an object (evaluating 'e.contentDocument')
  at None (./static/js/entry/zendesk_widget.js:154:26)
  at promiseReactionJob ([native code])
alicewriteswrongs commented 4 years ago

happens here in entry/zendesk_widget.js:

        // and the changes we make will be visible to the user.
        wait(100).then(() => {
          const ticketIFrame = document.querySelector(
            "iframe.zEWidget-ticketSubmissionForm"
          )
          const select = ticketIFrame.contentDocument.querySelector("select")
          const optionValues = _.map(select.options, "value")
          if (optionValues.includes(programSlug)) {
            select.value = programSlug
          }
        })

I suspect that sometimes wait(100) just isn't long enough to ensure that the iframe has been created yet. We should either set up something to retry or we should catch this error and silence it.