question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

In IE11, repeat polyfill seems to fail when uncaught exception is thrown

See original GitHub issue

Bug report

Describe the bug

When testing in IE, I get a white screen when an uncaught exception is thrown rather than the standard error message page or something more user friendly.

To Reproduce

  1. yarn create next-app
  2. Add a throw new Error('boom') to the top of pages/index.js
  3. yarn dev
  4. Observe the difference between IE11 and other browsers

Expected behavior

IE11 should have the same behavior for this case as other browsers

Screenshots

Screen Shot 2020-03-25 at 4 47 29 PM

System information

  • OS: Windows 81
  • Browser IE11
  • Version of Next.js: 9.3.1

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
elliottsjcommented, Apr 28, 2020

Narrowed down the issue some more:

  • The error "TypeError: Object doesn't support property or method 'repeat'" occurs on the expression l(a.marker,"^").repeat(h) in the minified source file node_modules/next/dist/compiled/react-error-overlay/index.js.

  • The error is only produced when we throw an error at module execution time (rather than at render time).

    e.g. this is ok

    export default () => {
      throw new Error('this is a test');
      return <span>hello world</span>;
    };
    

    but this fails

    throw new Error('this is a test');
    export default () => (<span>hello world</span>);
    

Repro:

$ yarn create next-app my-app
$ cd my-app
$ echo "throw new Error('this is a test'); export default () => (<span>hello world</span>);" > pages/index.js
$ yarn dev

Open the app in IE11, and you’ll see the error:

IE11 JS console error

Observe that String.prototype.repeat is undefined when the l(a.marker,"^").repeat(h) expression is evaluated by replacing it with

(function(){console.log("String.prototype.repeat",String.prototype.repeat);return l(a.marker,"^").repeat(h);})()

e.g.

$ sed -i '' 's/l(a.marker,"^").repeat(h)/(function(){console.log("String.prototype.repeat",String.prototype.repeat);return l(a.marker,"^").repeat(h);})()/g' node_modules/next/dist/compiled/react-error-overlay/index.js
$ yarn dev
Annotation 2020-04-28 120248

So, the issue seems to be that Next.js’s polyfills module is not being loaded prior to executing the pages/index.js module.

1reaction
timneutkenscommented, Apr 22, 2020

We can probably include it! Feel free to send a PR.

Read more comments on GitHub >

github_iconTop Results From Across the Web

In IE11, repeat polyfill seems to fail when uncaught exception ...
When testing in IE, I get a white screen when an uncaught exception is thrown rather than the standard error message page or...
Read more >
Angular 2 / 4 / 5 not working in IE11 - Stack Overflow
I was asked in the comments by @jackOfAll whether IE11 polyfills are loaded even if the user is in an evergreen browser which...
Read more >
String.prototype.replaceAll() - JavaScript - MDN Web Docs
A new string, with all matches of a pattern replaced by a replacement. Exceptions. TypeError. Thrown if the pattern is a regex that...
Read more >
Error Boundaries - React
Use static getDerivedStateFromError() to render a fallback UI after an error has been thrown. Use componentDidCatch() to log error information.
Read more >
Converse.js API Documentation Source: headless/dist ...
indexOf(chr); // Throw exception if character is not in the lookup string; ... else { throw new SyntaxError('[sprintf] failed to parse named argument...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found