detox 20.0.4-breaking.new-global-lifecycle.0 → 20.0.5-breaking.new-global-lifecycle.0
Sign up to get free protection for your applications and to get access to all the features.
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-javadoc.jar → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-sources.jar → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar} +0 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0-sources.jar.sha512 +1 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.aar → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar} +0 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.aar.md5 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.md5} +0 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.aar.sha1 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha1} +0 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.aar.sha256 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha256} +0 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.aar.sha512 → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.aar.sha512} +0 -0
- package/Detox-android/com/wix/detox/{20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.pom → 20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom} +1 -1
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.md5 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha1 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha256 +1 -0
- package/Detox-android/com/wix/detox/20.0.5-breaking.new-global-lifecycle.0/detox-20.0.5-breaking.new-global-lifecycle.0.pom.sha512 +1 -0
- package/Detox-android/com/wix/detox/maven-metadata.xml +4 -4
- package/Detox-android/com/wix/detox/maven-metadata.xml.md5 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha1 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha256 +1 -1
- package/Detox-android/com/wix/detox/maven-metadata.xml.sha512 +1 -1
- package/Detox-ios-src.tbz +0 -0
- package/Detox-ios.tbz +0 -0
- package/index.d.ts +49 -40
- package/internals.d.ts +63 -15
- package/local-cli/cli.js +1 -1
- package/local-cli/rebuild-framework-cache.js +1 -1
- package/local-cli/test.js +3 -2
- package/local-cli/test.test.js +1 -1
- package/local-cli/testCommand/TestRunnerCommand.js +4 -3
- package/package.json +5 -4
- package/runners/jest/globalSetup.js +1 -1
- package/runners/jest/globalTeardown.js +1 -1
- package/runners/jest/testEnvironment/index.js +33 -16
- package/runners/jest/testEnvironment/listeners/DetoxCoreListener.js +76 -41
- package/runners/jest/testEnvironment/listeners/SpecReporter.js +1 -1
- package/runners/jest/testEnvironment/listeners/WorkerAssignReporter.js +1 -1
- package/src/DetoxWorker.js +4 -1
- package/src/artifacts/ArtifactsManager.js +8 -23
- package/src/artifacts/instruments/ios/SimulatorInstrumentsRecording.js +3 -3
- package/src/artifacts/log/ios/SimulatorLogRecording.js +1 -1
- package/src/artifacts/screenshot/SimulatorScreenshotPlugin.js +1 -1
- package/src/artifacts/templates/artifact/Artifact.js +1 -1
- package/src/artifacts/templates/plugin/ArtifactPlugin.js +1 -1
- package/src/artifacts/utils/temporaryPath.js +18 -7
- package/src/artifacts/video/SimulatorRecordVideoPlugin.js +1 -1
- package/src/client/AsyncWebSocket.js +8 -17
- package/src/client/Client.js +1 -1
- package/src/configuration/collectCliConfig.js +1 -1
- package/src/configuration/composeDeviceConfig.js +1 -1
- package/src/configuration/composeLoggerConfig.js +17 -8
- package/src/configuration/composeRunnerConfig.js +1 -1
- package/src/configuration/index.js +5 -1
- package/src/configuration/loadExternalConfig.js +1 -1
- package/src/devices/allocation/DeviceAllocator.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/AVDValidator.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocDriver.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorAllocationHelper.js +1 -1
- package/src/devices/allocation/drivers/android/emulator/EmulatorLauncher.js +3 -2
- package/src/devices/allocation/drivers/android/emulator/EmulatorVersionResolver.js +4 -6
- package/src/devices/allocation/drivers/android/emulator/launchEmulatorProcess.js +1 -1
- package/src/devices/allocation/drivers/android/genycloud/GenyInstanceAllocationHelper.js +1 -1
- package/src/devices/common/drivers/android/genycloud/services/GenyInstanceNaming.js +3 -3
- package/src/devices/common/drivers/android/genycloud/services/GenyRecipesService.js +1 -1
- package/src/devices/common/drivers/android/tools/EmulatorTelnet.js +1 -1
- package/src/devices/common/drivers/android/tools/FreeDeviceFinder.js +1 -1
- package/src/devices/common/drivers/ios/tools/AppleSimUtils.js +1 -1
- package/src/devices/lifecycle/GenyGlobalLifecycleHandler.js +9 -13
- package/src/devices/runtime/RuntimeDevice.js +7 -8
- package/src/devices/runtime/drivers/DeviceDriverBase.js +1 -1
- package/src/devices/runtime/drivers/android/AndroidDriver.js +1 -1
- package/src/devices/runtime/drivers/ios/SimulatorDriver.js +1 -1
- package/src/ipc/IPCClient.js +3 -8
- package/src/ipc/IPCServer.js +11 -11
- package/src/ipc/{state.js → SessionState.js} +23 -50
- package/src/logger/DetoxLogger.js +264 -155
- package/src/logger/index.js +4 -0
- package/src/logger/utils/BunyanLogger.js +72 -0
- package/src/logger/utils/CategoryThreadDispatcher.js +58 -0
- package/src/logger/utils/MessageStack.js +24 -0
- package/src/logger/{TraceThreadDispatcher.js → utils/ThreadDispatcher.js} +34 -5
- package/src/logger/{customConsoleLogger.js → utils/customConsoleLogger.js} +4 -4
- package/src/logger/utils/sanitizeBunyanContext.js +28 -0
- package/src/logger/utils/tracerLegacy.js +25 -0
- package/src/realms/DetoxContext.js +65 -57
- package/src/realms/DetoxInternalsFacade.js +7 -5
- package/src/realms/DetoxPrimaryContext.js +111 -39
- package/src/realms/DetoxSecondaryContext.js +24 -29
- package/src/server/DetoxConnection.js +18 -23
- package/src/server/DetoxServer.js +7 -10
- package/src/server/DetoxSession.js +6 -6
- package/src/server/DetoxSessionManager.js +1 -1
- package/src/server/handlers/RegisteredConnectionHandler.js +1 -2
- package/src/symbols.js +12 -8
- package/src/utils/childProcess/exec.js +1 -1
- package/src/utils/childProcess/spawn.js +1 -1
- package/src/utils/streamUtils.js +10 -11
- package/src/utils/trace.js +2 -18
- package/src/utils/traceMethods.js +15 -0
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-javadoc.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-javadoc.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-javadoc.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-javadoc.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-sources.jar.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-sources.jar.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-sources.jar.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0-sources.jar.sha512 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.pom.md5 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.pom.sha1 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.pom.sha256 +0 -1
- package/Detox-android/com/wix/detox/20.0.4-breaking.new-global-lifecycle.0/detox-20.0.4-breaking.new-global-lifecycle.0.pom.sha512 +0 -1
- package/src/logger/DetoxTraceEventBuilder.js +0 -21
- package/src/logger/DetoxTracer.js +0 -133
- package/src/utils/ChromeTracingExporter.js +0 -54
@@ -1,12 +1,12 @@
|
|
1
1
|
const fs = require('fs');
|
2
2
|
|
3
3
|
const { DetoxInternalError } = require('../errors');
|
4
|
-
const
|
4
|
+
const SessionState = require('../ipc/SessionState');
|
5
5
|
const symbols = require('../symbols');
|
6
6
|
|
7
7
|
const DetoxContext = require('./DetoxContext');
|
8
8
|
|
9
|
-
const { $
|
9
|
+
const { $restoreSessionState, $sessionState, $worker } = DetoxContext.protected;
|
10
10
|
const _ipcClient = Symbol('ipcClient');
|
11
11
|
const _shortLifecycle = Symbol('shortLifecycle');
|
12
12
|
|
@@ -22,6 +22,8 @@ class DetoxSecondaryContext extends DetoxContext {
|
|
22
22
|
/**
|
23
23
|
* @private
|
24
24
|
* @type {undefined | boolean}
|
25
|
+
*
|
26
|
+
* TODO: explain what is short lifecycle and why we need it
|
25
27
|
*/
|
26
28
|
this[_shortLifecycle] = false;
|
27
29
|
}
|
@@ -40,59 +42,52 @@ class DetoxSecondaryContext extends DetoxContext {
|
|
40
42
|
}
|
41
43
|
|
42
44
|
/** @override */
|
43
|
-
async [symbols.
|
45
|
+
async [symbols.init](opts = {}) {
|
44
46
|
const IPCClient = require('../ipc/IPCClient');
|
45
47
|
|
46
48
|
this[_ipcClient] = new IPCClient({
|
47
49
|
id: `secondary-${process.pid}`,
|
48
50
|
state: this[$sessionState],
|
49
|
-
logger: this[
|
51
|
+
logger: this[symbols.logger],
|
50
52
|
});
|
51
53
|
|
52
54
|
await this[_ipcClient].init();
|
53
|
-
}
|
54
55
|
|
55
|
-
|
56
|
-
|
57
|
-
if (this[_ipcClient]) {
|
58
|
-
await this[_ipcClient].dispose();
|
59
|
-
this[_ipcClient] = null;
|
56
|
+
if (opts.workerId !== null) {
|
57
|
+
await this[symbols.installWorker](opts);
|
60
58
|
}
|
61
59
|
}
|
62
60
|
|
63
61
|
/** @override */
|
64
|
-
async [symbols.
|
65
|
-
if (!this[_ipcClient]) {
|
66
|
-
this[_shortLifecycle] = true;
|
67
|
-
await this[symbols.globalSetup]();
|
68
|
-
}
|
69
|
-
|
70
|
-
const workerId = opts.workerId || 1;
|
71
|
-
await this[_ipcClient].registerWorker(workerId);
|
72
|
-
await super[symbols.setup](opts);
|
73
|
-
}
|
74
|
-
|
75
|
-
/** @override */
|
76
|
-
async [symbols.teardown]() {
|
62
|
+
async [symbols.cleanup]() {
|
77
63
|
try {
|
78
|
-
|
64
|
+
if (this[$worker]) {
|
65
|
+
await this[symbols.uninstallWorker]();
|
66
|
+
}
|
79
67
|
} finally {
|
80
|
-
if (this[
|
81
|
-
await this[
|
68
|
+
if (this[_ipcClient]) {
|
69
|
+
await this[_ipcClient].dispose();
|
70
|
+
this[_ipcClient] = null;
|
82
71
|
}
|
83
72
|
}
|
84
73
|
}
|
74
|
+
|
75
|
+
/** @override */
|
76
|
+
async [symbols.installWorker](opts = {}) {
|
77
|
+
const workerId = opts.workerId = opts.workerId || 'worker';
|
78
|
+
await this[_ipcClient].registerWorker(workerId);
|
79
|
+
await super[symbols.installWorker](opts);
|
80
|
+
}
|
85
81
|
//#endregion
|
86
82
|
|
87
83
|
//#region Protected members
|
88
|
-
|
89
84
|
/**
|
90
85
|
* @protected
|
91
86
|
* @override
|
92
|
-
* @return {
|
87
|
+
* @return {SessionState}
|
93
88
|
*/
|
94
89
|
[$restoreSessionState]() {
|
95
|
-
return
|
90
|
+
return SessionState.parse(fs.readFileSync(process.env.DETOX_CONFIG_SNAPSHOT_PATH));
|
96
91
|
}
|
97
92
|
//#endregion
|
98
93
|
}
|
@@ -1,43 +1,37 @@
|
|
1
|
-
// @ts-nocheck
|
2
1
|
const _ = require('lodash');
|
3
|
-
const { WebSocket } = require('ws'); // eslint-disable-line @typescript-eslint/no-unused-vars, no-unused-vars
|
4
2
|
|
5
3
|
const DetoxRuntimeError = require('../errors/DetoxRuntimeError');
|
6
|
-
const logger = require('../utils/logger').child({
|
4
|
+
const logger = require('../utils/logger').child({ cat: 'ws-server,ws' });
|
7
5
|
|
8
6
|
const AnonymousConnectionHandler = require('./handlers/AnonymousConnectionHandler');
|
9
7
|
|
10
|
-
const EVENTS = {
|
11
|
-
NEW: { event: 'WSS_CONNECTION' },
|
12
|
-
GET: { event: 'WSS_GET_FROM' },
|
13
|
-
SEND: { event: 'WSS_SEND_TO' },
|
14
|
-
ERROR: { event: 'ERROR' },
|
15
|
-
SOCKET_ERROR: { event: 'WSS_SOCKET_ERROR' },
|
16
|
-
};
|
17
|
-
|
18
8
|
class DetoxConnection {
|
19
9
|
/**
|
20
|
-
* @param {
|
21
|
-
*
|
22
|
-
*
|
10
|
+
* @param {{
|
11
|
+
* sessionManager: import('./DetoxSessionManager');
|
12
|
+
* webSocket: import('ws');
|
13
|
+
* socket: import('net').Socket;
|
14
|
+
* }} config
|
23
15
|
*/
|
24
16
|
constructor({ sessionManager, webSocket, socket }) {
|
25
17
|
this._onMessage = this._onMessage.bind(this);
|
26
18
|
this._onError = this._onError.bind(this);
|
27
19
|
this._onClose = this._onClose.bind(this);
|
28
20
|
|
29
|
-
this._log = logger.child({
|
21
|
+
this._log = logger.child({ id: socket.remotePort });
|
22
|
+
this._log.debug.begin(`connection :${socket.localPort}<->:${socket.remotePort}`);
|
23
|
+
|
30
24
|
this._sessionManager = sessionManager;
|
31
25
|
this._webSocket = webSocket;
|
32
26
|
this._webSocket.on('message', this._onMessage);
|
33
27
|
this._webSocket.on('error', this._onError);
|
34
28
|
this._webSocket.on('close', this._onClose);
|
35
|
-
this._log.debug(EVENTS.NEW, 'registered a new connection.');
|
36
29
|
|
37
|
-
|
30
|
+
// eslint-disable-next-line unicorn/no-this-assignment
|
31
|
+
const self = this;
|
38
32
|
this._handler = new AnonymousConnectionHandler({
|
39
33
|
api: {
|
40
|
-
get log() { return
|
34
|
+
get log() { return self._log; },
|
41
35
|
appendLogDetails: (details) => { this._log = this._log.child(details); },
|
42
36
|
|
43
37
|
registerSession: (params) => this._sessionManager.registerSession(this, params),
|
@@ -49,13 +43,13 @@ class DetoxConnection {
|
|
49
43
|
|
50
44
|
sendAction(action) {
|
51
45
|
const messageAsString = JSON.stringify(action);
|
52
|
-
this._log.trace(
|
46
|
+
this._log.trace({ data: action }, 'send');
|
53
47
|
this._webSocket.send(messageAsString + '\n ');
|
54
48
|
}
|
55
49
|
|
56
50
|
_onMessage(rawData) {
|
57
51
|
const data = _.isString(rawData) ? rawData : rawData.toString('utf8');
|
58
|
-
this._log.trace(
|
52
|
+
this._log.trace({ data }, 'get');
|
59
53
|
|
60
54
|
try {
|
61
55
|
let action;
|
@@ -84,16 +78,17 @@ class DetoxConnection {
|
|
84
78
|
this._handler.onError(handlerError, action);
|
85
79
|
}
|
86
80
|
} catch (error) {
|
87
|
-
this._log.warn({
|
81
|
+
this._log.warn({ error }, 'Caught unhandled error:');
|
88
82
|
}
|
89
83
|
}
|
90
84
|
|
91
|
-
_onError(
|
92
|
-
this._log.warn(
|
85
|
+
_onError(error) {
|
86
|
+
this._log.warn({ error }, 'Caught socket error:');
|
93
87
|
}
|
94
88
|
|
95
89
|
_onClose() {
|
96
90
|
this._sessionManager.unregisterConnection(this._webSocket);
|
91
|
+
this._log.debug.end();
|
97
92
|
}
|
98
93
|
}
|
99
94
|
|
@@ -4,7 +4,7 @@ const WebSocket = require('ws');
|
|
4
4
|
|
5
5
|
const { DetoxInternalError, DetoxRuntimeError } = require('../errors');
|
6
6
|
const Deferred = require('../utils/Deferred');
|
7
|
-
const log = require('../utils/logger').child({
|
7
|
+
const log = require('../utils/logger').child({ cat: 'ws-server,ws' });
|
8
8
|
|
9
9
|
const DetoxSessionManager = require('./DetoxSessionManager');
|
10
10
|
|
@@ -40,18 +40,16 @@ class DetoxServer {
|
|
40
40
|
await this._startListening();
|
41
41
|
|
42
42
|
const level = this._options.standalone ? 'info' : 'debug';
|
43
|
-
log[level](
|
43
|
+
log[level](`Detox server listening on localhost:${this.port}...`);
|
44
44
|
}
|
45
45
|
|
46
46
|
async close() {
|
47
47
|
try {
|
48
48
|
await this._closeWithTimeout(10000);
|
49
|
-
log.debug(
|
50
|
-
} catch (
|
51
|
-
log.warn({
|
52
|
-
`Detox server has been closed abruptly! See the error details below
|
53
|
-
+ DetoxRuntimeError.format(e) + '\n'
|
54
|
-
+ DetoxRuntimeError.reportIssue
|
49
|
+
log.debug('Detox server has been closed gracefully');
|
50
|
+
} catch (err) {
|
51
|
+
log.warn({ err },
|
52
|
+
`Detox server has been closed abruptly! See the error details below:`
|
55
53
|
);
|
56
54
|
}
|
57
55
|
}
|
@@ -90,8 +88,7 @@ class DetoxServer {
|
|
90
88
|
} else if (this._closing) {
|
91
89
|
this._closing.reject(err);
|
92
90
|
} else {
|
93
|
-
|
94
|
-
log.error('Detox server has got an unhandled error:\n' + formattedError);
|
91
|
+
log.error({ err }, 'Detox server has got an unhandled error:');
|
95
92
|
}
|
96
93
|
}
|
97
94
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// @ts-nocheck
|
2
2
|
const DetoxInternalError = require('../errors/DetoxInternalError');
|
3
|
-
const log = require('../utils/logger').child({
|
3
|
+
const log = require('../utils/logger').child({ cat: 'ws-server,ws-session' });
|
4
4
|
|
5
5
|
class DetoxSession {
|
6
6
|
/**
|
@@ -17,7 +17,7 @@ class DetoxSession {
|
|
17
17
|
/** @type {boolean | null} */
|
18
18
|
this._pendingTesterStatus = null;
|
19
19
|
|
20
|
-
log.trace(
|
20
|
+
log.trace(`created session ${id}`);
|
21
21
|
}
|
22
22
|
|
23
23
|
get id() {
|
@@ -120,7 +120,7 @@ class DetoxSession {
|
|
120
120
|
}
|
121
121
|
|
122
122
|
_notifyAboutAppConnect() {
|
123
|
-
log.trace(
|
123
|
+
log.trace(`app joined session ${this.id}`);
|
124
124
|
|
125
125
|
if (!this._tester) {
|
126
126
|
return;
|
@@ -132,7 +132,7 @@ class DetoxSession {
|
|
132
132
|
}
|
133
133
|
|
134
134
|
_notifyAboutAppDisconnect() {
|
135
|
-
log.trace(
|
135
|
+
log.trace(`app exited session ${this.id}`);
|
136
136
|
|
137
137
|
if (!this._tester) {
|
138
138
|
return;
|
@@ -144,11 +144,11 @@ class DetoxSession {
|
|
144
144
|
}
|
145
145
|
|
146
146
|
_notifyAboutTesterConnect() {
|
147
|
-
log.trace(
|
147
|
+
log.trace(`tester joined session ${this.id}`);
|
148
148
|
}
|
149
149
|
|
150
150
|
_notifyAboutTesterDisconnect() {
|
151
|
-
log.trace(
|
151
|
+
log.trace(`tester exited session ${this.id}`);
|
152
152
|
|
153
153
|
if (!this._app) {
|
154
154
|
return;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
// @ts-nocheck
|
2
2
|
const DetoxInternalError = require('../errors/DetoxInternalError');
|
3
|
-
const log = require('../utils/logger').child({
|
3
|
+
const log = require('../utils/logger').child({ cat: 'ws-server,ws' });
|
4
4
|
|
5
5
|
const DetoxConnection = require('./DetoxConnection');
|
6
6
|
const DetoxSession = require('./DetoxSession');
|
@@ -1,7 +1,6 @@
|
|
1
1
|
// @ts-nocheck
|
2
2
|
const { serializeError } = require('serialize-error');
|
3
3
|
|
4
|
-
const DetoxError = require('../../errors/DetoxError');
|
5
4
|
const DetoxInternalError = require('../../errors/DetoxInternalError');
|
6
5
|
|
7
6
|
class RegisteredConnectionHandler {
|
@@ -41,7 +40,7 @@ class RegisteredConnectionHandler {
|
|
41
40
|
messageId: action && action.messageId,
|
42
41
|
});
|
43
42
|
} catch (err) {
|
44
|
-
this._api.log.error('Cannot forward the error details to the tester due to the error
|
43
|
+
this._api.log.error({ err }, 'Cannot forward the error details to the tester due to the error:');
|
45
44
|
throw error;
|
46
45
|
}
|
47
46
|
}
|
package/src/symbols.js
CHANGED
@@ -1,8 +1,11 @@
|
|
1
1
|
/**
|
2
2
|
* @type {{
|
3
|
+
* readonly cleanup: unique symbol;
|
3
4
|
* readonly config: unique symbol;
|
4
|
-
* readonly
|
5
|
-
* readonly
|
5
|
+
* readonly getStatus: unique symbol;
|
6
|
+
* readonly init: unique symbol;
|
7
|
+
* readonly installWorker: unique symbol;
|
8
|
+
* readonly logger: unique symbol;
|
6
9
|
* readonly onHookFailure: unique symbol;
|
7
10
|
* readonly onHookStart: unique symbol;
|
8
11
|
* readonly onHookSuccess: unique symbol;
|
@@ -18,8 +21,7 @@
|
|
18
21
|
* readonly reportFailedTests: unique symbol;
|
19
22
|
* readonly resolveConfig: unique symbol;
|
20
23
|
* readonly session: unique symbol;
|
21
|
-
* readonly
|
22
|
-
* readonly teardown: unique symbol;
|
24
|
+
* readonly uninstallWorker: unique symbol;
|
23
25
|
* readonly worker: unique symbol;
|
24
26
|
* }}
|
25
27
|
*/
|
@@ -44,13 +46,15 @@ module.exports = {
|
|
44
46
|
//#endregion
|
45
47
|
|
46
48
|
//#region Main
|
49
|
+
cleanup: Symbol('cleanup'),
|
47
50
|
config: Symbol('config'),
|
48
|
-
|
49
|
-
|
51
|
+
getStatus: Symbol('getStatus'),
|
52
|
+
init: Symbol('init'),
|
53
|
+
installWorker: Symbol('installWorker'),
|
54
|
+
logger: Symbol('logger'),
|
50
55
|
resolveConfig: Symbol('resolveConfig'),
|
51
56
|
session: Symbol('session'),
|
52
|
-
|
53
|
-
teardown: Symbol('teardown'),
|
57
|
+
uninstallWorker: Symbol('uninstallWorker'),
|
54
58
|
worker: Symbol('worker'),
|
55
59
|
//#endregion
|
56
60
|
};
|
@@ -3,7 +3,7 @@ const { exec } = require('child-process-promise');
|
|
3
3
|
const _ = require('lodash');
|
4
4
|
|
5
5
|
const DetoxRuntimeError = require('../../errors/DetoxRuntimeError');
|
6
|
-
const rootLogger = require('../logger').child({
|
6
|
+
const rootLogger = require('../logger').child({ cat: ['child-process', 'child-process-exec'] });
|
7
7
|
const retry = require('../retry');
|
8
8
|
|
9
9
|
const execsCounter = require('./opsCounter');
|
@@ -2,7 +2,7 @@
|
|
2
2
|
const { spawn } = require('child-process-promise');
|
3
3
|
const _ = require('lodash');
|
4
4
|
|
5
|
-
const rootLogger = require('../logger').child({
|
5
|
+
const rootLogger = require('../logger').child({ cat: ['child-process', 'child-process-spawn'] });
|
6
6
|
const { escape } = require('../pipeCommands');
|
7
7
|
const retry = require('../retry');
|
8
8
|
|
package/src/utils/streamUtils.js
CHANGED
@@ -8,9 +8,7 @@ const JsonlParser = require('stream-json/jsonl/Parser');
|
|
8
8
|
const stripAnsi = require('strip-ansi');
|
9
9
|
const { AbstractEventBuilder } = require('trace-event-lib');
|
10
10
|
|
11
|
-
const
|
12
|
-
|
13
|
-
const log = require('./logger').child({ __filename });
|
11
|
+
const log = require('./logger').child({ cat: 'logger' });
|
14
12
|
|
15
13
|
function compareTimestamps(a, b) {
|
16
14
|
return +(a.value.time > b.value.time) - +(a.value.time < b.value.time);
|
@@ -136,6 +134,7 @@ class JsonlStringer extends Transform {
|
|
136
134
|
|
137
135
|
class SimpleEventBuilder extends AbstractEventBuilder {
|
138
136
|
events = [];
|
137
|
+
|
139
138
|
send(event) {
|
140
139
|
this.events.push(event);
|
141
140
|
}
|
@@ -147,8 +146,7 @@ function chromeTraceStream() {
|
|
147
146
|
|
148
147
|
return flatMapTransform((data) => {
|
149
148
|
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
150
|
-
const {
|
151
|
-
const tid = trace ? trace.tid : DetoxTracer.threadize(args.cat);
|
149
|
+
const { cat = 'default', msg: name, ph = 'i', pid, tid, time, name: _name, hostname: _hostname, ...args } = data;
|
152
150
|
const ts = new Date(time).getTime() * 1E3;
|
153
151
|
|
154
152
|
const builder = new SimpleEventBuilder();
|
@@ -159,14 +157,15 @@ function chromeTraceStream() {
|
|
159
157
|
|
160
158
|
const tidHash = `${pid}:${tid}`;
|
161
159
|
if (!knownTids.has(tidHash)) {
|
162
|
-
|
160
|
+
const primaryCategory = cat.split(',', 1)[0];
|
161
|
+
builder.thread_name(primaryCategory, tid, pid);
|
163
162
|
builder.thread_sort_index(tid, tid, pid);
|
164
163
|
knownTids.add(tidHash);
|
165
164
|
}
|
166
165
|
|
167
|
-
const event = { ph
|
168
|
-
if (
|
169
|
-
event.name
|
166
|
+
const event = { ph, name, pid, tid, cat, ts, args };
|
167
|
+
if (ph === 'E') {
|
168
|
+
delete event.name;
|
170
169
|
}
|
171
170
|
|
172
171
|
builder.events.push(event);
|
@@ -190,11 +189,11 @@ function preventErrorSubscriptions(emitter) {
|
|
190
189
|
}
|
191
190
|
|
192
191
|
function readJSONL() {
|
193
|
-
const readable =
|
192
|
+
const readable = through();
|
194
193
|
const writable = JsonlParser.make({ checkErrors: true })
|
195
194
|
.on('error', (err) => {
|
196
195
|
if (err instanceof SyntaxError) {
|
197
|
-
log.debug({
|
196
|
+
log.debug({ err });
|
198
197
|
readable.end();
|
199
198
|
} else {
|
200
199
|
readable.emit('error', err);
|
package/src/utils/trace.js
CHANGED
@@ -1,19 +1,3 @@
|
|
1
|
-
|
2
|
-
const trace = require('../..').trace;
|
3
|
-
const traceCall = trace.bind(null);
|
1
|
+
const { trace, traceCall } = require('../..');
|
4
2
|
|
5
|
-
|
6
|
-
for (const name of methodNames) {
|
7
|
-
const originalMethod = obj[name];
|
8
|
-
|
9
|
-
obj[name] = function tracedMethod() {
|
10
|
-
return traceCall({ cat, name }, originalMethod.apply.bind(originalMethod, obj, arguments));
|
11
|
-
};
|
12
|
-
}
|
13
|
-
}
|
14
|
-
|
15
|
-
module.exports = {
|
16
|
-
trace,
|
17
|
-
traceCall,
|
18
|
-
traceMethods,
|
19
|
-
};
|
3
|
+
module.exports = { trace, traceCall };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
function traceMethods(logger, obj, methodNames) {
|
2
|
+
for (const name of methodNames) {
|
3
|
+
const originalMethod = obj[name];
|
4
|
+
|
5
|
+
obj[name] = function tracedMethod(...args) {
|
6
|
+
return logger.trace.complete(
|
7
|
+
{ args },
|
8
|
+
name,
|
9
|
+
originalMethod.apply.bind(originalMethod, obj, args)
|
10
|
+
);
|
11
|
+
};
|
12
|
+
}
|
13
|
+
}
|
14
|
+
|
15
|
+
module.exports = traceMethods;
|
@@ -1 +0,0 @@
|
|
1
|
-
4b124d7ab9e2288b4321b82987147ed7
|
@@ -1 +0,0 @@
|
|
1
|
-
f63f383626ed499ea635330561ee65f67926ade7
|
@@ -1 +0,0 @@
|
|
1
|
-
f73cf8db8e2a2d9f007e8f0e1b10c8a3206425ff5b48eecab8780d32adbb12fb
|
@@ -1 +0,0 @@
|
|
1
|
-
e21d314a45864e21cbea7bf17e9d23814def296e92b3b75ce64ca504f68d3b9aedc17c1beecd90407b9cb6e04803eb2d9ea4e2b9b4791ef34fc6aab597150770
|
@@ -1 +0,0 @@
|
|
1
|
-
4a9616f1535e129e7eeddbcc6d20b383
|
@@ -1 +0,0 @@
|
|
1
|
-
ab806e0458f9ffdadb4b758f356e55afd5c47db2
|
@@ -1 +0,0 @@
|
|
1
|
-
407c01beb305d15307e9defed1c41b643e01db58a1f15a4fa68b177e0ef7de49
|
@@ -1 +0,0 @@
|
|
1
|
-
0f48a23d1840085fd5b5c044f6fd4a9e7b898f5498d4ec22b94b94d42eed3982060aea614347d73ee97e57de200d17d8100aee99c569fb8fc1d3e9c9a5fc7911
|
@@ -1 +0,0 @@
|
|
1
|
-
7a767580cccb826b804646d27377aed1
|
@@ -1 +0,0 @@
|
|
1
|
-
157c429db5c60554c8098801c65193871427d41d
|
@@ -1 +0,0 @@
|
|
1
|
-
e5c436ef487d630e7685b412f6160f33be799f64b99b928cdfbaa2c41aa0561e
|
@@ -1 +0,0 @@
|
|
1
|
-
6894a1d7a895abc41593948227786e0a41428bcaee4f4246cb9b8b3d40dc50f6b1404d622a07adbd992397ff7687ba97f8020528666ee77cf66db9377eb4b206
|
@@ -1,21 +0,0 @@
|
|
1
|
-
const { AbstractEventBuilder } = require('trace-event-lib');
|
2
|
-
|
3
|
-
class DetoxTraceEventBuilder extends AbstractEventBuilder {
|
4
|
-
constructor(forward) {
|
5
|
-
super();
|
6
|
-
|
7
|
-
this._forward = forward;
|
8
|
-
}
|
9
|
-
|
10
|
-
send(event) {
|
11
|
-
// eslint-disable-next-line no-unused-vars, @typescript-eslint/no-unused-vars
|
12
|
-
const { pid, ts, name, args = {}, ...trace } = event;
|
13
|
-
if (trace.ph === 'E') {
|
14
|
-
this._forward({ ...args, trace }, `end`);
|
15
|
-
} else {
|
16
|
-
this._forward({ ...args, trace }, name);
|
17
|
-
}
|
18
|
-
}
|
19
|
-
}
|
20
|
-
|
21
|
-
module.exports = DetoxTraceEventBuilder;
|