inngest 3.53.0 → 3.54.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/Fetch.js +5 -5
- package/components/Fetch.js.map +1 -1
- package/components/InngestCommHandler.cjs +1 -4
- package/components/InngestCommHandler.cjs.map +1 -1
- package/components/InngestCommHandler.d.cts.map +1 -1
- package/components/InngestCommHandler.d.ts.map +1 -1
- package/components/InngestCommHandler.js +3 -6
- package/components/InngestCommHandler.js.map +1 -1
- package/components/connect/buffer.js +2 -2
- package/components/connect/buffer.js.map +1 -1
- package/components/connect/index.js +2 -2
- package/components/connect/index.js.map +1 -1
- package/components/connect/strategies/core/BaseStrategy.js +2 -2
- package/components/connect/strategies/core/BaseStrategy.js.map +1 -1
- package/components/execution/InngestExecution.js +2 -2
- package/components/execution/InngestExecution.js.map +1 -1
- package/components/execution/otel/middleware.js +9 -9
- package/components/execution/otel/middleware.js.map +1 -1
- package/components/execution/otel/processor.js +10 -10
- package/components/execution/otel/processor.js.map +1 -1
- package/package.json +1 -1
- package/version.cjs +1 -1
- package/version.cjs.map +1 -1
- package/version.d.cts +1 -1
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
package/components/Fetch.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { getAsyncCtx } from "./execution/als.js";
|
|
2
2
|
import { gatewaySymbol } from "./InngestStepTools.js";
|
|
3
|
-
import
|
|
3
|
+
import Debug from "debug";
|
|
4
4
|
|
|
5
5
|
//#region src/components/Fetch.ts
|
|
6
6
|
const globalFetch = globalThis.fetch;
|
|
7
|
-
const debug
|
|
7
|
+
const debug = Debug("inngest:fetch");
|
|
8
8
|
const createFetchShim = () => {
|
|
9
9
|
let stepFetch;
|
|
10
10
|
const fetch$1 = async (input, init) => {
|
|
11
11
|
const ctx = await getAsyncCtx();
|
|
12
12
|
if (!ctx?.execution) {
|
|
13
13
|
if (!stepFetch.fallback) throw new Error("step.fetch() called outside of a function and had no fallback set");
|
|
14
|
-
debug
|
|
14
|
+
debug("step.fetch() called outside of a function; falling back to global fetch");
|
|
15
15
|
return stepFetch.fallback(input, init);
|
|
16
16
|
}
|
|
17
17
|
if (ctx.execution.executingStep) {
|
|
18
18
|
if (!stepFetch.fallback) throw new Error(`step.fetch() called inside step "${ctx.execution.executingStep.id}" and had no fallback set`);
|
|
19
|
-
debug
|
|
19
|
+
debug(`step.fetch() called inside step "${ctx.execution.executingStep.id}"; falling back to global fetch`);
|
|
20
20
|
return stepFetch.fallback(input, init);
|
|
21
21
|
}
|
|
22
22
|
const targetUrl = new URL(input instanceof Request ? input.url : input.toString());
|
|
23
|
-
debug
|
|
23
|
+
debug("step.fetch() shimming request to", targetUrl.hostname);
|
|
24
24
|
const jsonRes = await ctx.execution.ctx.step[gatewaySymbol](`step.fetch: ${targetUrl.hostname}`, input, init);
|
|
25
25
|
return new Response(jsonRes.body, {
|
|
26
26
|
headers: jsonRes.headers,
|
package/components/Fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.js","names":["
|
|
1
|
+
{"version":3,"file":"Fetch.js","names":["stepFetch: StepFetch","fetch: Fetch","optionsRef: StepFetch.Options","extras: StepFetch.Extras","fetch"],"sources":["../../src/components/Fetch.ts"],"sourcesContent":["import Debug from \"debug\";\nimport type { Simplify } from \"../helpers/types.ts\";\nimport { getAsyncCtx } from \"./execution/als.ts\";\nimport { gatewaySymbol, type InternalStepTools } from \"./InngestStepTools.ts\";\n\nconst globalFetch = globalThis.fetch;\ntype Fetch = typeof globalFetch;\n\nexport type StepFetch = Fetch &\n Simplify<\n {\n config: (options: StepFetch.Options) => StepFetch;\n } & Readonly<StepFetch.Options>\n >;\n\nexport namespace StepFetch {\n export interface Options {\n fallback?: Fetch | undefined;\n }\n\n export interface Extras extends Options {\n config: (options: Options) => StepFetch;\n }\n}\n\nconst debug = Debug(\"inngest:fetch\");\n\nconst createFetchShim = (): StepFetch => {\n // biome-ignore lint/style/useConst: need this to allow fns to be defined\n let stepFetch: StepFetch;\n\n const fetch: Fetch = async (input, init) => {\n const ctx = await getAsyncCtx();\n if (!ctx?.execution) {\n // Not in a function run\n if (!stepFetch.fallback) {\n // TODO Tell the user how to solve\n throw new Error(\n \"step.fetch() called outside of a function and had no fallback set\",\n );\n }\n\n debug(\n \"step.fetch() called outside of a function; falling back to global fetch\",\n );\n\n return stepFetch.fallback(input, init);\n }\n\n // In a function run\n if (ctx.execution.executingStep) {\n // Inside a step\n if (!stepFetch.fallback) {\n // TODO Tell the user how to solve\n throw new Error(\n `step.fetch() called inside step \"${ctx.execution.executingStep.id}\" and had no fallback set`,\n );\n }\n\n debug(\n `step.fetch() called inside step \"${ctx.execution.executingStep.id}\"; falling back to global fetch`,\n );\n\n return stepFetch.fallback(input, init);\n }\n\n // TODO Do we need to make this better with deferred (global) step tooling?\n // hmmmmm\n\n const targetUrl = new URL(\n input instanceof Request ? input.url : input.toString(),\n );\n\n debug(\"step.fetch() shimming request to\", targetUrl.hostname);\n\n // Purposefully do not try/cacth this; if it throws then we treat that as a\n // regular `fetch()` throw, which also would not return a `Response`.\n const jsonRes = await (ctx.execution.ctx.step as InternalStepTools)[\n gatewaySymbol\n ](`step.fetch: ${targetUrl.hostname}`, input, init);\n\n return new Response(jsonRes.body, {\n headers: jsonRes.headers,\n status: jsonRes.status_code,\n });\n };\n\n const optionsRef: StepFetch.Options = {\n fallback: globalFetch,\n };\n\n const extras: StepFetch.Extras = {\n config: (options) => {\n Object.assign(optionsRef, options);\n Object.assign(stepFetch, optionsRef);\n\n return stepFetch;\n },\n ...optionsRef,\n };\n\n stepFetch = Object.assign(fetch, extras);\n\n return stepFetch;\n};\n\n/**\n * `fetch` is a Fetch API-compatible function that can be used to make any HTTP\n * code durable if it's called within an Inngest function.\n *\n * It will gracefully fall back to the global `fetch` if called outside of this\n * context, and a custom fallback can be set using the `config` method.\n *\n * @example Basic usage\n * ```ts\n * import { fetch } from \"inngest\";\n *\n * const api = new MyProductApi({ fetch });\n * ```\n *\n * @example Setting a custom fallback\n * ```ts\n * import { fetch } from \"inngest\";\n *\n * const api = new MyProductApi({\n * fetch: fetch.config({ fallback: myCustomFetch }),\n * });\n * ```\n *\n * @example Do not allow fallback\n * ```ts\n * import { fetch } from \"inngest\";\n *\n * const api = new MyProductApi({\n * fetch: fetch.config({ fallback: undefined }),\n * });\n * ```\n */\nexport const fetch = createFetchShim();\n"],"mappings":";;;;;AAKA,MAAM,cAAc,WAAW;AAoB/B,MAAM,QAAQ,MAAM,gBAAgB;AAEpC,MAAM,wBAAmC;CAEvC,IAAIA;CAEJ,MAAMC,UAAe,OAAO,OAAO,SAAS;EAC1C,MAAM,MAAM,MAAM,aAAa;AAC/B,MAAI,CAAC,KAAK,WAAW;AAEnB,OAAI,CAAC,UAAU,SAEb,OAAM,IAAI,MACR,oEACD;AAGH,SACE,0EACD;AAED,UAAO,UAAU,SAAS,OAAO,KAAK;;AAIxC,MAAI,IAAI,UAAU,eAAe;AAE/B,OAAI,CAAC,UAAU,SAEb,OAAM,IAAI,MACR,oCAAoC,IAAI,UAAU,cAAc,GAAG,2BACpE;AAGH,SACE,oCAAoC,IAAI,UAAU,cAAc,GAAG,iCACpE;AAED,UAAO,UAAU,SAAS,OAAO,KAAK;;EAMxC,MAAM,YAAY,IAAI,IACpB,iBAAiB,UAAU,MAAM,MAAM,MAAM,UAAU,CACxD;AAED,QAAM,oCAAoC,UAAU,SAAS;EAI7D,MAAM,UAAU,MAAO,IAAI,UAAU,IAAI,KACvC,eACA,eAAe,UAAU,YAAY,OAAO,KAAK;AAEnD,SAAO,IAAI,SAAS,QAAQ,MAAM;GAChC,SAAS,QAAQ;GACjB,QAAQ,QAAQ;GACjB,CAAC;;CAGJ,MAAMC,aAAgC,EACpC,UAAU,aACX;CAED,MAAMC,SAA2B;EAC/B,SAAS,YAAY;AACnB,UAAO,OAAO,YAAY,QAAQ;AAClC,UAAO,OAAO,WAAW,WAAW;AAEpC,UAAO;;EAET,GAAG;EACJ;AAED,aAAY,OAAO,OAAOC,SAAO,OAAO;AAExC,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmCT,MAAa,QAAQ,iBAAiB"}
|
|
@@ -1060,10 +1060,7 @@ var InngestCommHandler = class {
|
|
|
1060
1060
|
this.log("error", `Received unhandled HTTP method "${method}" (type: ${typeof method}); expected POST, PUT, or GET`);
|
|
1061
1061
|
return {
|
|
1062
1062
|
status: 405,
|
|
1063
|
-
body: JSON.stringify({
|
|
1064
|
-
message: `No action found; expected POST, PUT, or GET but received "${method}"`,
|
|
1065
|
-
mode: this._mode
|
|
1066
|
-
}),
|
|
1063
|
+
body: JSON.stringify({ message: `No action found; expected POST, PUT, or GET but received "${method}"` }),
|
|
1067
1064
|
headers: {},
|
|
1068
1065
|
version: void 0
|
|
1069
1066
|
};
|