Skip to content

Commit

Permalink
fix: surface openSSL unhandled rejection errors that occur within plu…
Browse files Browse the repository at this point in the history
…gin code (#19553)

Co-authored-by: Matt Henkes <[email protected]>
  • Loading branch information
emilyrohrbough and mjhenkes committed Jan 5, 2022
1 parent df5687c commit a81fa26
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/server/lib/plugins/child/browser_launch.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module.exports = {
// TODO: remove in next breaking release
// This will send a warning message when a deprecated API is used
// define array-like functions on this object so we can warn about using deprecated array API
// while still fufiling desired behavior
// while still fulfilling desired behavior
const [, launchOptions] = args

let hasEmittedWarning = false
Expand Down
11 changes: 9 additions & 2 deletions packages/server/lib/plugins/child/run_plugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,16 @@ const runPlugins = (ipc, pluginsFile, projectRoot) => {
})

process.on('unhandledRejection', (event) => {
const err = (event && event.reason) || event
let err = event

debug('unhandled rejection:', event)

// Rejected Bluebird promises will return a reason object.
// OpenSSL error returns a reason as user-friendly string.
if (event && event.reason && typeof event.reason === 'object') {
err = event.reason
}

debug('unhandled rejection:', util.serializeError(err))
ipc.send('error', util.serializeError(err))

return false
Expand Down
8 changes: 7 additions & 1 deletion packages/server/test/unit/plugins/child/run_plugins_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -408,10 +408,16 @@ describe('lib/plugins/child/run_plugins', () => {
expect(this.ipc.send).to.be.calledWith('error', this.err)
})

it('sends the serialized reason via ipc on process unhandledRejection', function () {
it('sends the serialized Bluebird error via ipc on process unhandledRejection', function () {
process.on.withArgs('unhandledRejection').yield({ reason: this.err })

expect(this.ipc.send).to.be.calledWith('error', this.err)
})

it('sends the serialized OpenSSL error via ipc on process unhandledRejection', function () {
process.on.withArgs('unhandledRejection').yield({ ...this.err, reason: 'reason' })

expect(this.ipc.send).to.be.calledWith('error', this.err)
})
})
})

3 comments on commit a81fa26

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a81fa26 Jan 5, 2022

Choose a reason for hiding this comment

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

Circle has built the linux x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.2.1/circle-develop-a81fa26c8922c2558372d414e391afe3dc2440a6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a81fa26 Jan 5, 2022

Choose a reason for hiding this comment

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

Circle has built the win32 x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.2.1/circle-develop-a81fa26c8922c2558372d414e391afe3dc2440a6/cypress.tgz

@cypress-bot
Copy link
Contributor

@cypress-bot cypress-bot bot commented on a81fa26 Jan 5, 2022

Choose a reason for hiding this comment

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

Circle has built the darwin x64 version of the Test Runner.

Learn more about this pre-release platform-specific build at https://on.cypress.io/installing-cypress#Install-pre-release-version.

Run this command to install the pre-release locally:

npm install https://cdn.cypress.io/beta/npm/9.2.1/circle-develop-a81fa26c8922c2558372d414e391afe3dc2440a6/cypress.tgz

Please sign in to comment.