Skip to content

Commit

Permalink
add necessary worker ternminate and more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
CurryYangxx committed May 13, 2024
1 parent df2cb91 commit a0d2f5e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/insomnia/src/ui/routes/actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,7 @@ export const generateCollectionAndTestsAction: ActionFunction = async ({ params
const spectralRunner = new SpectralRunner();

const results = (await spectralRunner.runDiagnostics({ contents: apiSpec.contents, rulesetPath })).filter(isLintError);
spectralRunner.terminate();
if (apiSpec.contents && results && results.length) {
throw new Error('Error Generating Configuration');
}
Expand Down
2 changes: 1 addition & 1 deletion packages/insomnia/src/ui/worker/spectral.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const cachedRuleset: {
ruleset: oas as RulesetDefinition,
};

const loadRuleset = async (rulesetPath: string,) => {
const loadRuleset = async (rulesetPath: string) => {
if (cachedRuleset.path === rulesetPath) {
return cachedRuleset.ruleset;
}
Expand Down
4 changes: 4 additions & 0 deletions packages/insomnia/src/ui/worker/spetral-run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ export class SpectralRunner {
// onmessage callback will be called several times in one promise, and promise can be resolved or rejected only once, so we cant reject it here
if (id === this.taskId && diagnostics) {
resolve(diagnostics);
} else if (diagnostics) {
console.log('Received diagnostics for old task, ignoring');
} else {
console.error('Error while running diagnostics:', e.data);
}
};

Expand Down

0 comments on commit a0d2f5e

Please sign in to comment.