Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .travis.yml
Original file line numberDiff line numberDiff line change
Expand Up@@ -3,7 +3,7 @@ sudo: false
dist: trusty
cache: yarn
node_js:
- 8
- 10
env:
global:
- BROWSER_PROVIDER_READY_FILE=/tmp/sauce-connect-ready
Expand Down
8 changes: 6 additions & 2 deletions lib/common/events.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -10,7 +10,7 @@
* @suppress {missingRequire}
*/

import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils';
import {ADD_EVENT_LISTENER_STR, attachOriginToPatched, FALSE_STR, isNode, ObjectGetPrototypeOf, REMOVE_EVENT_LISTENER_STR, TRUE_STR, ZONE_SYMBOL_PREFIX, zoneSymbol} from './utils';

/** @internal **/
interface EventTaskData extends TaskData {
Expand DownExpand Up@@ -330,10 +330,15 @@ export function patchEventTarget(
returnTarget = false, prepend = false) {
return function() {
const target = this || _global;
const eventName = arguments[0];
let delegate = arguments[1];
if (!delegate) {
return nativeListener.apply(this, arguments);
}
if (isNode && eventName === 'uncaughtException') {
// don't patch uncaughtException of nodejs to prevent endless loop
return nativeListener.apply(this, arguments);
}

// don't create the bind delegate function for handleEvent
// case here to improve addEventListener performance
Expand All@@ -350,7 +355,6 @@ export function patchEventTarget(
return;
}

const eventName = arguments[0];
const options = arguments[2];

if (blackListedEvents) {
Expand Down
8 changes: 7 additions & 1 deletion test/node/events.spec.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -183,4 +183,10 @@ describe('nodejs EventEmitter', () => {
expect(emitter.listeners('removeListener').length).toBe(0);
});
});
});
it('should not enter endless loop when register uncaughtException to process', () => {
require('domain');
zoneA.run(() => {
process.on('uncaughtException', function() {});
});
});
});
Loading