Fix silent request query property
MODIFY
internal/core/server/Server.ts
internal/core/server/Server.ts
@@ -724,14 +724,6 @@ export default class Server {
throw new Error("Expected bridgeEndEvent to have been initialized");
}
- // Support a silent option on requests so they don't write output
- let reporter = client.reporter;
- if (query.silent) {
- reporter = reporter.fork({
- streams: [],
- });
- }
-
const req = new ServerRequest({
client,
query,
@@ -792,7 +784,7 @@ export default class Server {
const warmupTook = Date.now() - warmupStart;
// Benchmark
- const progress = client.reporter.progress({title: markup`Running benchmark`});
+ const progress = req.reporter.progress({title: markup`Running benchmark`});
progress.setTotal(benchmarkIterations);
const benchmarkStart = Date.now();
for (let i = 0; i < benchmarkIterations; i++) {

MODIFY
internal/core/server/ServerRequest.ts
internal/core/server/ServerRequest.ts
@@ -140,13 +140,28 @@ export class ServerRequestCancelled extends Error {
}
export default class ServerRequest {
- constructor(opts: ServerRequestOptions) {
- this.query = opts.query;
- this.server = opts.server;
- this.bridge = opts.client.bridge;
- this.reporter = opts.client.reporter;
+ constructor({query, server, client}: ServerRequestOptions) {
+ this.query = query;
+ this.server = server;
+ this.bridge = client.bridge;
+ this.reporter = query.silent ? new Reporter() : client.reporter;
+ this.client = client;
+
+ this.start = Date.now();
+ this.id = requestIdCounter++;
this.cancelled = false;
this.toredown = false;
+ this.markers = [];
+ this.normalizedCommandFlags = {
+ flags: {},
+ defaultFlags: {},
+ };
+ this.files = new AbsoluteFilePathMap();
+
+ this.logger = server.logger.namespace(
+ markup`[ServerRequest] Request #${this.id}:`,
+ );
+
this.markerEvent = new Event({
name: "ServerRequest.marker",
onError: this.server.onFatalErrorBound,
@@ -156,21 +171,8 @@ export default class ServerRequest {
onError: this.server.onFatalErrorBound,
serial: true,
});
- this.client = opts.client;
- this.id = requestIdCounter++;
- this.markers = [];
- this.start = Date.now();
- this.normalizedCommandFlags = {
- flags: {},
- defaultFlags: {},
- };
- this.client.requestsInFlight.add(this);
-
- this.files = new AbsoluteFilePathMap();
- this.logger = opts.server.logger.namespace(
- markup`[ServerRequest] Request #${this.id}:`,
- );
+ this.client.requestsInFlight.add(this);
}
id: number;

Fix silent request query property (#928)