fix: throw an error instead of ignoring it when uploading batches - #207
fix: throw an error instead of ignoring it when uploading batches#207gasperzgonec wants to merge 12 commits into
Conversation
27ba842 to
7a4fc6e
Compare
|
|
|
- Revert defensive logFn guard in spawn.ts (unrelated to this fix, logFn is always a function on the real Logger). - Rename canEmit to prepared and document beforeEmit's return contract. - Collapse sendToPlatform/afterEmit into a single emitToPlatform method, matching the beforeEmit/buildEmitPayload/afterEmit shape used in v2. - Inline emitUploadFailure into beforeEmit's catch block since it had a single call site. - Run eslint --fix to clean up pre-existing formatting violations.
|
Matches v2's adapter shape (beforeEmit/buildEmitPayload/afterEmit, no separate sendToPlatform/emitToPlatform helper) per review feedback. beforeEmit no longer swallows the repo-upload failure itself; emit() catches it, collects partial artifacts, and picks the error event type before sending, so there's a single call site for the actual platform emit and its WorkerMessageEmitted/WorkerMessageExit outcome handling.
|
# Conflicts: # src/multithreading/worker-adapter/worker-adapter.ts
| console.log( | ||
| `Uploading all repos before emitting event with event type: ${newEventType}.` | ||
| ); | ||
| // Uploading all repos can fail partway through. When it does, we still |
There was a problem hiding this comment.
Can you re-check this with @GasperSenk. Is it true that we want to report artifacts with failure?
| // we emit an error event for the current phase instead of the | ||
| // originally requested event type. | ||
| let eventTypeToEmit = newEventType; | ||
| let payload: EventData; |
There was a problem hiding this comment.
Rename to eventPayload.
| console.error('Error while posting state', error); | ||
| parentPort?.postMessage(WorkerMessageSubject.WorkerMessageExit); | ||
| this.hasWorkerEmitted = true; | ||
| const prepared = await this.beforeEmit(newEventType); |
There was a problem hiding this comment.
Prepared what? Let's try to have better naming here. Also what happens if "it is not prepared" and we just return here?
| * flushing repos again, so artifacts uploaded before the failure are still | ||
| * reported without retrying the failed batch. | ||
| */ | ||
| async emitFailure(error: unknown): Promise<void> { |
There was a problem hiding this comment.
Maybe rename to emitError so we have it unified across the whole sdk. Also if I am not wrong this is used only in process-task, right? Can it be reused for all situations where we emit error? I imagine behaviour is the same.
| return error; | ||
| throw new Error( | ||
| error?.message ?? | ||
| `Upload failed for item type "${this.itemType}" without artifact.` |
There was a problem hiding this comment.
What does this message mean?
Description
Connected Issues
Checklist
npm run testOR no tests needed.npm run test:backwards-compatibility.npm run lint.