Skip to content

Commit

Permalink
fix!: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Badisi committed Aug 14, 2024
1 parent 5bf1074 commit 093b183
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion projects/lib/specs/schematics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@ describe('schematics', () => {

it('helper: getSchematicSchemaOptions - non existing package external', async () => {
const test$ = getSchematicSchemaOptions(context, 'sentry', '@hug/non-existing-package', true, 0);
await expectAsync(test$).toBeRejectedWith('Request error (404): https://cdn.jsdelivr.net//npm/@hug/non-existing-package@latest/package.json');
await expectAsync(test$).toBeRejectedWithError('Request error (404): https://cdn.jsdelivr.net//npm/@hug/non-existing-package@latest/package.json');
});
});
6 changes: 3 additions & 3 deletions projects/lib/src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 3
try {
resolve(Buffer.concat(rawData));
} catch (err) {
reject(err);
reject((err instanceof Error) ? err : new Error(String(err)));
}
});
} else if (retries > 0) {
setTimeout(() => void getDataFromUrl(url, retries - 1, backoff * 2), backoff);
} else {
res.removeAllListeners();
res.resume(); // consume response data to free up memory
reject(`Request error (${String(res.statusCode)}): https://${hostname}/${pathname}`);
reject(new Error(`Request error (${String(res.statusCode)}): https://${hostname}/${pathname}`));
}
});
const abort = (error: Error | string): void => {
Expand All @@ -40,7 +40,7 @@ export const getDataFromUrl = async (url: string | URL, retries = 3, backoff = 3
} else {
req.removeAllListeners();
req.destroy();
reject(error);
reject((error instanceof Error) ? error : new Error(String(error)));
}
};
req.once('timeout', () => abort(`Request timed out: https://${hostname}/${pathname}`));
Expand Down

0 comments on commit 093b183

Please sign in to comment.