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

Capture and log page errors #374

Merged
merged 8 commits into from
Sep 15, 2021
Merged

Capture and log page errors #374

merged 8 commits into from
Sep 15, 2021

Conversation

shahzad31
Copy link
Contributor

@shahzad31 shahzad31 commented Sep 13, 2021

Fixes #226

Add an event handler in browser console for "pageerror".

Capturing error.message and error.stack.toString()

@apmmachine
Copy link

apmmachine commented Sep 13, 2021

❕ Build Aborted

Either there was a build timeout or someone aborted the build.'}

the below badges are clickable and redirect to their specific view in the CI or DOCS
Pipeline View Test View Changes Artifacts preview

Expand to view the summary

Build stats

  • Start Time: 2021-09-15T15:24:57.701+0000

  • Duration: 28 min 18 sec

  • Commit: df5d3d7

Test stats 🧪

Test Results
Failed 0
Passed 125
Skipped 0
Total 125

Trends 🧪

Image of Build Times

Image of Tests

Log output

Expand to view the last 100 lines of log output

[2021-09-15T15:35:36.508Z]  > git checkout -f df5d3d777a73269c792c788b1818a5632153ec3b # timeout=15
[2021-09-15T15:35:40.934Z] Commit message: "Merge branch 'catch-exceptions' of github.com:elastic/synthetics into catch-exceptions"
[2021-09-15T15:35:40.934Z] Cleaning workspace
[2021-09-15T15:35:40.937Z]  > git rev-parse --verify HEAD # timeout=10
[2021-09-15T15:35:40.941Z] Resetting working tree
[2021-09-15T15:35:40.941Z]  > git reset --hard # timeout=10
[2021-09-15T15:35:40.958Z]  > git clean -fdx # timeout=10
[2021-09-15T15:35:43.030Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/src/github.com/elastic/synthetics
[2021-09-15T15:35:59.283Z] + set +x
[2021-09-15T15:35:59.284Z] => Downloading nvm from git to '/var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/.nvm'
[2021-09-15T15:35:59.284Z] 
=> Initialized empty Git repository in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/.nvm/.git/
[2021-09-15T15:35:59.854Z] From https://github.com/nvm-sh/nvm
[2021-09-15T15:35:59.854Z]  * [new tag]         v0.37.1    -> v0.37.1
[2021-09-15T15:35:59.854Z] => Compressing and cleaning up git repository
[2021-09-15T15:35:59.854Z] 
[2021-09-15T15:35:59.854Z] => Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.
[2021-09-15T15:35:59.854Z] => Create one of them and run this script again
[2021-09-15T15:35:59.854Z]    OR
[2021-09-15T15:35:59.854Z] => Append the following lines to the correct file yourself:
[2021-09-15T15:35:59.854Z] 
[2021-09-15T15:35:59.854Z] export NVM_DIR="$HOME/.nvm"
[2021-09-15T15:35:59.854Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-09-15T15:35:59.854Z] 
[2021-09-15T15:36:01.762Z] => Close and reopen your terminal to start using nvm or run the following to use it now:
[2021-09-15T15:36:01.762Z] 
[2021-09-15T15:36:01.762Z] export NVM_DIR="$HOME/.nvm"
[2021-09-15T15:36:01.762Z] [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[2021-09-15T15:36:01.762Z] Found '/var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/src/github.com/elastic/synthetics/.nvmrc' with version <14.17.5>
[2021-09-15T15:36:02.022Z] v14.17.5 is already installed.
[2021-09-15T15:36:02.282Z] Now using node v14.17.5 (npm v6.14.14)
[2021-09-15T15:36:02.282Z] /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374
[2021-09-15T15:36:02.453Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/src/github.com/elastic/synthetics
[2021-09-15T15:36:02.749Z] + chmod -R ugo+rw examples
[2021-09-15T15:36:02.770Z] Running in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/src/github.com/elastic/synthetics/__tests__/e2e
[2021-09-15T15:36:03.066Z] + npm run test
[2021-09-15T15:36:03.067Z] 
[2021-09-15T15:36:03.067Z] > e2e-synthetics@ test /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/src/github.com/elastic/synthetics/__tests__/e2e
[2021-09-15T15:36:03.067Z] > npm i && npm run setup &&  bash scripts/test.sh
[2021-09-15T15:36:03.067Z] 
[2021-09-15T15:36:06.362Z] added 3 packages from 4 contributors and audited 184 packages in 2.585s
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] 69 packages are looking for funding
[2021-09-15T15:36:08.902Z]   run `npm fund` for details
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] found 0 vulnerabilities
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] > e2e-synthetics@ setup /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/src/github.com/elastic/synthetics/__tests__/e2e
[2021-09-15T15:36:08.902Z] > bash scripts/setup.sh
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] Temporary folder
[2021-09-15T15:36:08.902Z] Temporary files will be stored in: ./tmp
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] Starting elasticsearch , kibana and synthetics docker
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] 
[2021-09-15T15:36:08.902Z] Waiting for synthetics docker to start...
[2021-09-15T15:36:08.902Z] Error: No such object: synthetics
[2021-09-15T15:36:18.893Z] Error: No such object: synthetics
[2021-09-15T15:36:31.122Z] Error: No such object: synthetics
[2021-09-15T15:36:39.290Z] Error: No such object: synthetics
[2021-09-15T15:36:49.466Z] Error: No such object: synthetics
[2021-09-15T15:36:59.456Z] Error: No such object: synthetics
[2021-09-15T15:37:09.445Z] Error: No such object: synthetics
[2021-09-15T15:37:19.552Z] Error: No such object: synthetics
[2021-09-15T15:37:29.597Z] ✅ Setup completed successfully. Running e2e tests...
[2021-09-15T15:37:31.014Z] Waiting for Elastic Search  to start
[2021-09-15T15:38:09.973Z] Waiting for Synthetics to send data to ES for test monitor
[2021-09-15T15:39:17.808Z] Waiting for kibana server to start
[2021-09-15T15:53:02.973Z] Cancelling nested steps due to timeout
[2021-09-15T15:53:02.979Z] Sending interrupt signal to process
[2021-09-15T15:53:10.341Z] scripts/test.sh: line 26:  6320 Terminated              SYNTHETICS_JUNIT_FILE='junit.xml' npx @elastic/synthetics uptime.journey.ts --reporter junit
[2021-09-15T15:53:10.341Z] npm ERR! code ELIFECYCLE
[2021-09-15T15:53:10.341Z] npm ERR! errno 143
[2021-09-15T15:53:10.341Z] npm ERR! e2e-synthetics@ test: `npm i && npm run setup &&  bash scripts/test.sh`
[2021-09-15T15:53:10.341Z] npm ERR! Exit status 143
[2021-09-15T15:53:10.341Z] npm ERR! 
[2021-09-15T15:53:10.341Z] npm ERR! Failed at the e2e-synthetics@ test script.
[2021-09-15T15:53:10.341Z] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
[2021-09-15T15:53:10.341Z] 
[2021-09-15T15:53:10.341Z] npm ERR! A complete log of this run can be found in:
[2021-09-15T15:53:10.341Z] npm ERR!     /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374/.npm/_logs/2021-09-15T15_53_03_407Z-debug.log
[2021-09-15T15:53:10.351Z] script returned exit code 143
[2021-09-15T15:53:12.120Z] Post stage
[2021-09-15T15:53:12.211Z] Archiving artifacts
[2021-09-15T15:53:12.562Z] Recording test results
[2021-09-15T15:53:12.975Z] None of the test reports contained any result
[2021-09-15T15:53:12.996Z] [Checks API] No suitable checks publisher found.
[2021-09-15T15:53:13.285Z] Stage "Release" skipped due to earlier failure(s)
[2021-09-15T15:53:13.321Z] Stage "Release" skipped due to earlier failure(s)
[2021-09-15T15:53:13.396Z] Stage "Release" skipped due to earlier failure(s)
[2021-09-15T15:53:14.376Z] Running on Jenkins in /var/lib/jenkins/workspace/nt-rum_elastic-synthetics_PR-374
[2021-09-15T15:53:14.451Z] [INFO] getVaultSecret: Getting secrets
[2021-09-15T15:53:14.573Z] Masking supported pattern matches of $VAULT_ADDR or $VAULT_ROLE_ID or $VAULT_SECRET_ID
[2021-09-15T15:53:15.696Z] + chmod 755 generate-build-data.sh
[2021-09-15T15:53:15.696Z] + ./generate-build-data.sh https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-374/ https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-374/runs/7 ABORTED 1697631
[2021-09-15T15:53:15.696Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-374/runs/7/steps/?limit=10000 -o steps-info.json
[2021-09-15T15:53:16.607Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-374/runs/7/tests/?status=FAILED -o tests-errors.json
[2021-09-15T15:53:17.157Z] INFO: curl https://apm-ci.elastic.co/blue/rest/organizations/jenkins/pipelines/apm-agent-rum/elastic-synthetics/PR-374/runs/7/log/ -o pipeline-log.txt

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for working on this, tests can be written in browser-console.test.ts, where you can throw some promise errors inside the evaluate function.

    await page.evaluate(() => Promise.reject(new Error("Boom")));
    // make sure to add some stack here and do the needful. 

Let me know if you need any help.

src/plugins/browser-console.ts Outdated Show resolved Hide resolved
src/plugins/browser-console.ts Show resolved Hide resolved
src/common_types.ts Outdated Show resolved Hide resolved
@shahzad31
Copy link
Contributor Author

@vigneshshanmugam i have added a unit test

Copy link
Member

@vigneshshanmugam vigneshshanmugam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, can you add a test for promise rejection as well.

src/reporters/json.ts Show resolved Hide resolved
__tests__/plugins/browser-console.test.ts Outdated Show resolved Hide resolved
__tests__/plugins/browser-console.test.ts Outdated Show resolved Hide resolved
@shahzad31
Copy link
Contributor Author

Looking good, can you add a test for promise rejection as well.

@vigneshshanmugam promoise rejections doesnt let the test run. I think current test cover enough scenerios.

@vigneshshanmugam
Copy link
Member

@vigneshshanmugam promoise rejections doesnt let the test run. I think current test cover enough scenerios.

Probably its a problem then, The intention of the original issue was to capture unhandled exceptions. Will merge once i test it out.

@vigneshshanmugam vigneshshanmugam merged commit 7cbca0a into master Sep 15, 2021
@vigneshshanmugam vigneshshanmugam deleted the catch-exceptions branch September 15, 2021 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
7.16-candidate enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

capture unhandled exception on tested pages
3 participants