From 31b09f8abf069a52ad0d78f3d4c317de1f95d627 Mon Sep 17 00:00:00 2001 From: mattcompiles Date: Fri, 12 Apr 2024 22:26:06 +1000 Subject: [PATCH] Add logging for failed dev dep requests --- packages/core/core/src/RequestTracker.js | 15 ++++++++++++++- packages/core/core/src/requests/DevDepRequest.js | 6 +++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/core/core/src/RequestTracker.js b/packages/core/core/src/RequestTracker.js index 689f9a390c7..09ff9f9d852 100644 --- a/packages/core/core/src/RequestTracker.js +++ b/packages/core/core/src/RequestTracker.js @@ -1166,7 +1166,8 @@ export default class RequestTracker { request: Request, opts?: ?RunRequestOpts, ): Promise { - let requestId = this.graph.hasContentKey(request.id) + let hasKey = this.graph.hasContentKey(request.id); + let requestId = hasKey ? this.graph.getNodeIdByContentKey(request.id) : undefined; let hasValidResult = requestId != null && this.hasValidResult(requestId); @@ -1224,6 +1225,18 @@ export default class RequestTracker { deferred.resolve(true); return result; } catch (err) { + if (request.type === requestTypes.dev_dep_request) { + logger.verbose({ + origin: '@parcel/core', + message: `Failed DevDepRequest`, + meta: { + trackableEvent: 'failed_dev_dep_request', + hasKey, + hasValidResult, + }, + }); + } + this.rejectRequest(requestNodeId); deferred.resolve(false); throw err; diff --git a/packages/core/core/src/requests/DevDepRequest.js b/packages/core/core/src/requests/DevDepRequest.js index eb1d93d5aa4..1d0be3e2f1f 100644 --- a/packages/core/core/src/requests/DevDepRequest.js +++ b/packages/core/core/src/requests/DevDepRequest.js @@ -191,13 +191,17 @@ export async function runDevDepRequest( id: 'dev_dep_request:' + devDepRequest.specifier + ':' + devDepRequest.hash, type: requestTypes.dev_dep_request, run: ({api}) => { - for (let filePath of nullthrows(devDepRequest.invalidateOnFileChange)) { + for (let filePath of nullthrows( + devDepRequest.invalidateOnFileChange, + 'DevDepRequest missing invalidateOnFileChange', + )) { api.invalidateOnFileUpdate(filePath); api.invalidateOnFileDelete(filePath); } for (let invalidation of nullthrows( devDepRequest.invalidateOnFileCreate, + 'DevDepRequest missing invalidateOnFileCreate', )) { api.invalidateOnFileCreate(invalidation); }