Use node-fetch for invokeEphemeralEvents instead of @whatwg-node/fetch (#734)
🚀 Publish Trigger.dev Docker / typecheck (push) Failing after 0s
🚀 Publish Trigger.dev Docker / units (push) Failing after 0s
🚀 Publish Trigger.dev Docker / e2e (push) Failing after 0s
🚀 Publish Trigger.dev Docker / publish (push) Has been skipped

This commit is contained in:
Matt Aitken
2023-11-10 17:36:21 +00:00
committed by GitHub
parent af57bc208a
commit 0afa119721
@@ -1,7 +1,6 @@
import { PrismaClient, PrismaClientOrTransaction, prisma } from "~/db.server";
import { taskOperationWorker } from "../worker.server";
import { EphemeralDispatchableSchema } from "~/models/eventDispatcher.server";
import { fetch } from "@whatwg-node/fetch";
import { ExpireDispatcherService } from "./expireDispatcher.server";
export class InvokeEphemeralDispatcherService {
@@ -61,23 +60,14 @@ export class InvokeEphemeralDispatcherService {
accountId: eventRecord.externalAccount ? eventRecord.externalAccount.identifier : undefined,
};
const abortController = new AbortController();
const timeoutId = setTimeout(() => {
abortController.abort();
}, 5000);
const response = await fetch(url, {
method: "POST",
headers: {
"Content-Type": "application/json; charset=utf-8",
},
body: JSON.stringify(body),
signal: abortController.signal,
});
clearTimeout(timeoutId);
if (!response.ok) {
throw new Error(
`Failed to invoke ephemeral dispatcher: ${response.statusText} [${response.status}]`