Fix errors being swallowed by bridge
MODIFY
packages/@romejs/core/common/bridges/WorkerBridge.ts
packages/@romejs/core/common/bridges/WorkerBridge.ts
@@ -248,7 +248,7 @@ export default class WorkerBridge extends Bridge {
}
return {
- diagnostic: err.diagnostics,
+ diagnostics: err.diagnostics,
};
},
hydrate(err, data) {

MODIFY
packages/@romejs/core/master/Master.ts
packages/@romejs/core/master/Master.ts
@@ -456,6 +456,32 @@ export default class Master {
return await worker.bridge.profilingStop.call();
});
+ // When enableWorkerLogs is called we setup subscriptions to the worker logs
+ // Logs are never transported from workers to the master unless there is a subscription
+ let subscribedWorkers = false;
+ bridge.enableWorkerLogs.subscribe(() => {
+ // enableWorkerLogs could be called twice in the case of `--logs --rage`. We'll only want to setup the subscriptions once
+ if (subscribedWorkers) {
+ return;
+ } else {
+ subscribedWorkers = true;
+ }
+
+ function onLog(chunk: string) {
+ bridge.log.call({origin: 'worker', chunk});
+ }
+
+ // Add on existing workers if there are any
+ for (const worker of this.workerManager.getWorkers()) {
+ bridge.attachEndSubscriptionRemoval(worker.bridge.log.subscribe(onLog));
+ }
+
+ // Listen for logs for any workers that start later
+ this.workerManager.workerStartEvent.subscribe((worker) => {
+ bridge.attachEndSubscriptionRemoval(worker.log.subscribe(onLog));
+ });
+ });
+
await bridge.handshake();
const client = await this.createClient(bridge);
@@ -574,32 +600,6 @@ export default class Master {
this.connectedClients.add(client);
- // When enableWorkerLogs is called we setup subscriptions to the worker logs
- // Logs are never transported from workers to the master unless there is a subscription
- let subscribedWorkers = false;
- bridge.enableWorkerLogs.subscribe(() => {
- // enableWorkerLogs could be called twice in the case of `--logs --rage`. We'll only want to setup the subscriptions once
- if (subscribedWorkers) {
- return;
- } else {
- subscribedWorkers = true;
- }
-
- function onLog(chunk: string) {
- bridge.log.call({origin: 'worker', chunk});
- }
-
- // Add on existing workers if there are any
- for (const worker of this.workerManager.getWorkers()) {
- bridge.attachEndSubscriptionRemoval(worker.bridge.log.subscribe(onLog));
- }
-
- // Listen for logs for any workers that start later
- this.workerManager.workerStartEvent.subscribe((worker) => {
- bridge.attachEndSubscriptionRemoval(worker.log.subscribe(onLog));
- });
- });
-
bridge.updatedListenersEvent.subscribe((listeners) => {
if (listeners.has('log')) {
this.connectedClientsListeningForLogs.add(client);

MODIFY
packages/@romejs/core/worker/WorkerAPI.ts
packages/@romejs/core/worker/WorkerAPI.ts
@@ -112,7 +112,7 @@ export default class WorkerAPI {
return UNKNOWN_ANALYZE_DEPENDENCIES_RESULT;
}
- return analyzeDependencies({
+ return await analyzeDependencies({
file: ref,
project,
worker: this.worker,

MODIFY
packages/@romejs/events/Bridge.ts
packages/@romejs/events/Bridge.ts
@@ -205,11 +205,8 @@ export default class Bridge {
}
// Notify the other side of what we're currently subscribed to
-
// We send over a list of all of our subscriptions every time
-
// This is fine since we don't change subscriptions often and they aren't very large
-
// If we have a lot of subscriptions, or are changing them a lot in the future then this could be optimized
this.sendMessage({
type: 'subscriptions',

MODIFY
packages/@romejs/events/BridgeEvent.ts
packages/@romejs/events/BridgeEvent.ts
@@ -110,7 +110,11 @@ export default class BridgeEvent<
// @ts-ignore
callbacks.resolve(data.value);
} else if (data.responseStatus === 'error') {
+ try {
callbacks.reject(this.bridge.buildError(data.value, data.metadata));
+ } catch (err) {
+ callbacks.reject(err);
+ }
} else {
// ???
}

Fix errors being swallowed by bridge