Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for timeouts #2037

Closed
felixfbecker opened this issue Feb 15, 2018 · 6 comments
Closed

Improve error message for timeouts #2037

felixfbecker opened this issue Feb 15, 2018 · 6 comments

Comments

@felixfbecker
Copy link

When a page.waitFor() times out, this is all error context a dev gets:

     Error: waiting failed: timeout 30000ms exceeded
      at Timeout.WaitTask._timeoutTimer.setTimeout (node_modules/puppeteer/lib/FrameManager.js:695:58)

No stack trace and no indication what operation timed out.

An easy change to an error message like

     Error: waiting for selector ".my-selector" failed: timeout 30000ms exceeded
      at Timeout.WaitTask._timeoutTimer.setTimeout (node_modules/puppeteer/lib/FrameManager.js:695:58)

would make a huge difference in knowing where to look.

@aslushnikov
Copy link
Contributor

I'll be happy to review a PR.

@felixfbecker
Copy link
Author

felixfbecker commented Feb 23, 2018

I was also able to get long stack traces by patching global Promise with bluebird (which still has the most robust long stack traces implementation I've seen):

const Bluebird = require('bluebird')
Bluebird.config({ longStackTraces: true })
global.Promise = Bluebird
  Error: waiting failed: timeout 30000ms exceeded
      at Timeout.WaitTask._timeoutTimer.setTimeout [as _onTimeout] (node_modules/puppeteer/lib/FrameManager.js:789:58)
  From previous event:
      at new WaitTask (node_modules/puppeteer/lib/FrameManager.js:783:20)
      at Frame.waitForFunction (node_modules/puppeteer/lib/FrameManager.js:675:12)
      at Frame._waitForSelectorOrXPath (node_modules/puppeteer/lib/FrameManager.js:695:17)
      at Frame.waitForSelector (node_modules/puppeteer/lib/FrameManager.js:655:17)
      at Page.waitForSelector (node_modules/puppeteer/lib/Page.js:874:29)
      at Context.it (src/e2e/index.test.e2e.tsx:122:24)
      at <anonymous>

There currently is no native way to maintain stack traces with setTimeout in Node.

@Saturate
Copy link
Contributor

Including bluebird just for this seems rather excessive. Is this on the Node roadmap?

@felixfbecker
Copy link
Author

I don't think so. Async call stacks when using setTimeout for the debugger have been fixed in Node 9.6.1 but async error stack traces was never supported by Node.

@felixfbecker
Copy link
Author

felixfbecker commented Feb 23, 2018

Also personally don't really have a problem with a 194KB devDependency if I get long stack traces in return. The benefit it huge, what's the cost? I don't use any Bluebird API, the application sees no difference.

@ianldgs
Copy link

ianldgs commented Feb 24, 2018

Suggestion:
instantiate an Error before setTimeout. If it timesout, throw the instantiated Error

aslushnikov pushed a commit that referenced this issue Mar 30, 2018
This patch adds title for WaitTask, using it later in generating error messages and
making exceptions much more traceable.

Fixes #2037
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants