@shipfox/api-server 5.0.0 → 6.0.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.
@@ -1,2 +1,2 @@
1
1
  $ shipfox-swc
2
- Successfully compiled: 6 files with swc (80.74ms)
2
+ Successfully compiled: 6 files with swc (362.72ms)
package/CHANGELOG.md CHANGED
@@ -1,5 +1,93 @@
1
1
  # @shipfox/api-server
2
2
 
3
+ ## 6.0.0
4
+
5
+ ### Minor Changes
6
+
7
+ - 23563de: Moves Triggers to the injected Workflows inter-module contract with stable run idempotency and listener delivery commands.
8
+ - add4c77: Adds host-configurable runners composition with batched installation workspace eligibility policy.
9
+ - c0162b0: Adds a bounded lifecycle for non-Temporal API module services.
10
+ - f262539: Adds a composed webhook processor and optional provider-neutral delivery source for hosted API runtimes.
11
+ - a01e917: Passes a per-initialization outbox registry through module startup, workers, and dispatch services instead of process-global state.
12
+ - a42b575: Exposes Secrets through its inter-module contract and migrates Agent, integrations, and Workflows consumers.
13
+
14
+ ### Patch Changes
15
+
16
+ - a8f0545: Adds the versioned Definitions workflow snapshot contract and registered presentation.
17
+ - 0bb82a4: Adds the Agent and Integrations inter-module APIs, moving Workflows agent configuration, runtime credential resolution, and integration consumers behind producer-owned clients.
18
+ - ba2e3dc: Migrates password email verification from magic links to shared eight-digit email challenges.
19
+ - f73da5d: Enforces bounded API context imports and routes inter-module consumers through producer contracts.
20
+ - 23a4dc2: Moves Logs and Integrations to injected Workflows inter-module clients with minimal log and leased agent-tool queries.
21
+ - Updated dependencies [e52513c]
22
+ - Updated dependencies [7b449a1]
23
+ - Updated dependencies [905b6a3]
24
+ - Updated dependencies [a8f0545]
25
+ - Updated dependencies [0bb82a4]
26
+ - Updated dependencies [9cb2442]
27
+ - Updated dependencies [b70f920]
28
+ - Updated dependencies [23563de]
29
+ - Updated dependencies [7366f04]
30
+ - Updated dependencies [6a52909]
31
+ - Updated dependencies [e6eba5b]
32
+ - Updated dependencies [54ce48b]
33
+ - Updated dependencies [add4c77]
34
+ - Updated dependencies [9006b75]
35
+ - Updated dependencies [3cda0c6]
36
+ - Updated dependencies [ba2e3dc]
37
+ - Updated dependencies [c0162b0]
38
+ - Updated dependencies [7ac43a4]
39
+ - Updated dependencies [f262539]
40
+ - Updated dependencies [a01e917]
41
+ - Updated dependencies [3bb4e26]
42
+ - Updated dependencies [1b79cda]
43
+ - Updated dependencies [c2db8c3]
44
+ - Updated dependencies [822b8c5]
45
+ - Updated dependencies [a42b575]
46
+ - Updated dependencies [112c0fa]
47
+ - Updated dependencies [8ce515b]
48
+ - Updated dependencies [8bdc149]
49
+ - Updated dependencies [795e293]
50
+ - Updated dependencies [e10c829]
51
+ - Updated dependencies [f73da5d]
52
+ - Updated dependencies [6bdf24b]
53
+ - Updated dependencies [3810996]
54
+ - Updated dependencies [23a4dc2]
55
+ - Updated dependencies [b00ed29]
56
+ - Updated dependencies [8aa7cd3]
57
+ - Updated dependencies [326f4c0]
58
+ - Updated dependencies [1820feb]
59
+ - Updated dependencies [4a91956]
60
+ - Updated dependencies [81f9544]
61
+ - Updated dependencies [4604a06]
62
+ - Updated dependencies [6741be8]
63
+ - @shipfox/api-runners@6.0.0
64
+ - @shipfox/api-runners-dto@6.0.0
65
+ - @shipfox/api-dispatcher@6.0.0
66
+ - @shipfox/api-email-challenges@0.2.0
67
+ - @shipfox/api-definitions-dto@6.0.0
68
+ - @shipfox/api-definitions@6.0.0
69
+ - @shipfox/api-workflows@6.0.0
70
+ - @shipfox/api-agent-dto@6.0.0
71
+ - @shipfox/api-agent@6.0.0
72
+ - @shipfox/api-integration-core-dto@6.0.0
73
+ - @shipfox/api-integration-core@6.0.0
74
+ - @shipfox/api-projects@6.0.0
75
+ - @shipfox/annotations@6.0.0
76
+ - @shipfox/annotations-dto@6.0.0
77
+ - @shipfox/api-triggers@6.0.0
78
+ - @shipfox/api-workflows-dto@6.0.0
79
+ - @shipfox/api-auth@6.0.0
80
+ - @shipfox/api-workspaces@6.0.0
81
+ - @shipfox/node-jwt@0.3.0
82
+ - @shipfox/api-auth-dto@6.0.0
83
+ - @shipfox/node-module@0.4.0
84
+ - @shipfox/api-workspaces-dto@6.0.0
85
+ - @shipfox/api-secrets@6.0.0
86
+ - @shipfox/api-secrets-dto@6.0.0
87
+ - @shipfox/api-logs@6.0.0
88
+ - @shipfox/node-fastify@0.2.4
89
+ - @shipfox/api-projects-dto@6.0.0
90
+
3
91
  ## 5.0.0
4
92
 
5
93
  ### Patch Changes
package/README.md CHANGED
@@ -42,7 +42,7 @@ node --import @shipfox/api-server/instrumentation ./dist/index.js
42
42
 
43
43
  - **Custom composition**: Pass a module list to make a custom server. A module must declare a unique `loginMethods` entry. `createServer` throws before startup side effects when no login method is available.
44
44
  - **Signal handling**: `createServer` does not install signal handlers.
45
- - **Lifecycle**: `start` starts workers before the HTTP listener. `stop` is safe to call again.
45
+ - **Lifecycle**: `start` starts workers and module services before the HTTP listener. `stop` is safe to call again. It stops services before workers and shared clients.
46
46
  - **Process scope**: Run one server at a time.
47
47
 
48
48
  ## Development
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { defaultModules } from './modules.js';
1
+ export { type DefaultModulesOptions, defaultModules } from './modules.js';
2
2
  export type { CreateServerOptions, RunServerOptions, ServerHandle } from './server.js';
3
3
  export { createServer, runServer } from './server.js';
4
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAC,MAAM,cAAc,CAAC;AAC5C,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,KAAK,qBAAqB,EAAE,cAAc,EAAC,MAAM,cAAc,CAAC;AACxE,YAAY,EAAC,mBAAmB,EAAE,gBAAgB,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AACrF,OAAO,EAAC,YAAY,EAAE,SAAS,EAAC,MAAM,aAAa,CAAC"}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {defaultModules} from './modules.js';\nexport type {CreateServerOptions, RunServerOptions, ServerHandle} from './server.js';\nexport {createServer, runServer} from './server.js';\n"],"names":["defaultModules","createServer","runServer"],"mappings":"AAAA,SAAQA,cAAc,QAAO,eAAe;AAE5C,SAAQC,YAAY,EAAEC,SAAS,QAAO,cAAc"}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["export {type DefaultModulesOptions, defaultModules} from './modules.js';\nexport type {CreateServerOptions, RunServerOptions, ServerHandle} from './server.js';\nexport {createServer, runServer} from './server.js';\n"],"names":["defaultModules","createServer","runServer"],"mappings":"AAAA,SAAoCA,cAAc,QAAO,eAAe;AAExE,SAAQC,YAAY,EAAEC,SAAS,QAAO,cAAc"}
package/dist/modules.d.ts CHANGED
@@ -1,3 +1,7 @@
1
+ import { type WebhookDeliverySource } from '@shipfox/api-integration-core';
1
2
  import type { ShipfoxModule } from '@shipfox/node-module';
2
- export declare function defaultModules(): Promise<ShipfoxModule[]>;
3
+ export interface DefaultModulesOptions {
4
+ webhookDeliverySource?: WebhookDeliverySource | undefined;
5
+ }
6
+ export declare function defaultModules(options?: DefaultModulesOptions): Promise<ShipfoxModule[]>;
3
7
  //# sourceMappingURL=modules.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAwBA,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAExD,wBAAsB,cAAc,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC,CAwF/D"}
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAWA,OAAO,EAA4B,KAAK,qBAAqB,EAAC,MAAM,+BAA+B,CAAC;AAepG,OAAO,KAAK,EAAC,aAAa,EAAC,MAAM,sBAAsB,CAAC;AAMxD,MAAM,WAAW,qBAAqB;IACpC,qBAAqB,CAAC,EAAE,qBAAqB,GAAG,SAAS,CAAC;CAC3D;AAED,wBAAsB,cAAc,CAClC,OAAO,GAAE,qBAA0B,GAClC,OAAO,CAAC,aAAa,EAAE,CAAC,CAiI1B"}
package/dist/modules.js CHANGED
@@ -1,104 +1,161 @@
1
1
  import { annotationsModule } from '@shipfox/annotations';
2
- import { agentModule } from '@shipfox/api-agent';
3
- import { authModule } from '@shipfox/api-auth';
2
+ import { annotationsInterModuleContract } from '@shipfox/annotations-dto/inter-module';
3
+ import { createAgentModule } from '@shipfox/api-agent';
4
+ import { agentInterModuleContract } from '@shipfox/api-agent-dto/inter-module';
5
+ import { createAuthModule } from '@shipfox/api-auth';
6
+ import { config as authConfig } from '@shipfox/api-auth/config';
7
+ import { authInterModuleContract } from '@shipfox/api-auth-dto/inter-module';
4
8
  import { createDefinitionsModule } from '@shipfox/api-definitions';
9
+ import { definitionsInterModuleContract } from '@shipfox/api-definitions-dto/inter-module';
5
10
  import { dispatcherModule } from '@shipfox/api-dispatcher';
6
- import { buildAgentToolCatalogs, buildAgentToolSelectionCatalogs, createIntegrationsContext, createWorkspaceConnectionSnapshotLoader, getIntegrationConnectionById } from '@shipfox/api-integration-core';
7
- import { logsModule } from '@shipfox/api-logs';
11
+ import { emailChallengesModule } from '@shipfox/api-email-challenges';
12
+ import { createIntegrationsContext } from '@shipfox/api-integration-core';
13
+ import { integrationsInterModuleContract } from '@shipfox/api-integration-core-dto';
14
+ import { createLogsModule } from '@shipfox/api-logs';
8
15
  import { createProjectsModule } from '@shipfox/api-projects';
9
- import { runnersModule } from '@shipfox/api-runners';
10
- import { deleteSecrets, getSecret, secretsModule, setSecrets } from '@shipfox/api-secrets';
11
- import { triggersModule } from '@shipfox/api-triggers';
12
- import { loadRunningLeasedStep, setAgentToolMaterializationServices, setSourceControl, workflowsModule } from '@shipfox/api-workflows';
16
+ import { projectsInterModuleContract } from '@shipfox/api-projects-dto';
17
+ import { createRunnersModule } from '@shipfox/api-runners';
18
+ import { runnersInterModuleContract } from '@shipfox/api-runners-dto/inter-module';
19
+ import { createSecretsModule } from '@shipfox/api-secrets';
20
+ import { secretsInterModuleContract } from '@shipfox/api-secrets-dto/inter-module';
21
+ import { createTriggersModule } from '@shipfox/api-triggers';
22
+ import { createWorkflowsModule } from '@shipfox/api-workflows';
23
+ import { workflowsInterModuleContract } from '@shipfox/api-workflows-dto/inter-module';
13
24
  import { workspacesModule } from '@shipfox/api-workspaces';
14
- export async function defaultModules() {
25
+ import { workspacesInterModuleContract } from '@shipfox/api-workspaces-dto/inter-module';
26
+ import { durationToSeconds } from '@shipfox/node-jwt';
27
+ import { createInMemoryInterModuleTransport, registerInterModulePresentations } from '@shipfox/node-module/inter-module';
28
+ export async function defaultModules(options = {}) {
29
+ const interModuleTransport = createInMemoryInterModuleTransport();
30
+ const workflowsClient = interModuleTransport.createClient(workflowsInterModuleContract);
31
+ const authClient = interModuleTransport.createClient(authInterModuleContract);
32
+ const agentClient = interModuleTransport.createClient(agentInterModuleContract);
33
+ const runnersClient = interModuleTransport.createClient(runnersInterModuleContract);
34
+ const projectsClient = interModuleTransport.createClient(projectsInterModuleContract);
35
+ const definitionsClient = interModuleTransport.createClient(definitionsInterModuleContract);
36
+ const annotationsClient = interModuleTransport.createClient(annotationsInterModuleContract);
37
+ const secretsClient = interModuleTransport.createClient(secretsInterModuleContract);
38
+ const workspacesClient = interModuleTransport.createClient(workspacesInterModuleContract);
39
+ const integrationsClient = interModuleTransport.createClient(integrationsInterModuleContract);
15
40
  const integrations = await createIntegrationsContext({
41
+ workspaces: workspacesClient,
16
42
  secrets: {
17
- deleteSecrets,
43
+ deleteSecrets: async (params)=>(await secretsClient.deleteSecrets(params)).deleted,
18
44
  linear: {
19
- getSecret: (params)=>getSecret({
45
+ getSecret: async (params)=>(await secretsClient.getSecret({
20
46
  ...params,
21
47
  namespace: `system/integrations/linear/${params.namespace}`
22
- }),
23
- setSecrets: (params)=>setSecrets({
48
+ })).value,
49
+ setSecrets: async (params)=>{
50
+ const { editedBy, ...secretParams } = params;
51
+ await secretsClient.setSecrets({
52
+ ...secretParams,
53
+ namespace: `system/integrations/linear/${secretParams.namespace}`,
54
+ ...editedBy === undefined ? {} : {
55
+ editedBy
56
+ }
57
+ });
58
+ },
59
+ deleteSecrets: async (params)=>(await secretsClient.deleteSecrets({
24
60
  ...params,
25
61
  namespace: `system/integrations/linear/${params.namespace}`
26
- }),
27
- deleteSecrets: (params)=>deleteSecrets({
28
- ...params,
29
- namespace: `system/integrations/linear/${params.namespace}`
30
- })
62
+ })).deleted
31
63
  },
32
64
  jira: {
33
- getSecret: (params)=>getSecret({
65
+ getSecret: async (params)=>(await secretsClient.getSecret({
34
66
  ...params,
35
67
  namespace: `system/integrations/jira/${params.namespace}`
36
- }),
37
- setSecrets: (params)=>setSecrets({
68
+ })).value,
69
+ setSecrets: async (params)=>{
70
+ const { editedBy, ...secretParams } = params;
71
+ await secretsClient.setSecrets({
72
+ ...secretParams,
73
+ namespace: `system/integrations/jira/${secretParams.namespace}`,
74
+ ...editedBy === undefined ? {} : {
75
+ editedBy
76
+ }
77
+ });
78
+ },
79
+ deleteSecrets: async (params)=>(await secretsClient.deleteSecrets({
38
80
  ...params,
39
81
  namespace: `system/integrations/jira/${params.namespace}`
40
- }),
41
- deleteSecrets: (params)=>deleteSecrets({
42
- ...params,
43
- namespace: `system/integrations/jira/${params.namespace}`
44
- })
82
+ })).deleted
45
83
  },
46
84
  slack: {
47
- getSecret: (params)=>getSecret({
85
+ getSecret: async (params)=>(await secretsClient.getSecret({
48
86
  ...params,
49
87
  namespace: `system/integrations/slack/${params.namespace}`
50
- }),
51
- setSecrets: (params)=>setSecrets({
88
+ })).value,
89
+ setSecrets: async (params)=>{
90
+ const { editedBy, ...secretParams } = params;
91
+ await secretsClient.setSecrets({
92
+ ...secretParams,
93
+ namespace: `system/integrations/slack/${secretParams.namespace}`,
94
+ ...editedBy === undefined ? {} : {
95
+ editedBy
96
+ }
97
+ });
98
+ },
99
+ deleteSecrets: async (params)=>(await secretsClient.deleteSecrets({
52
100
  ...params,
53
101
  namespace: `system/integrations/slack/${params.namespace}`
54
- }),
55
- deleteSecrets: (params)=>deleteSecrets({
56
- ...params,
57
- namespace: `system/integrations/slack/${params.namespace}`
58
- })
102
+ })).deleted
59
103
  }
60
104
  },
61
105
  agentTools: {
62
- loadLeasedAgentStep: loadRunningLeasedStep
63
- }
64
- });
65
- const [agentToolSelectionCatalogs, agentToolCatalogs] = await Promise.all([
66
- buildAgentToolSelectionCatalogs(integrations.registry),
67
- buildAgentToolCatalogs(integrations.registry)
68
- ]);
69
- const loadWorkspaceConnectionSnapshot = createWorkspaceConnectionSnapshotLoader(integrations.registry);
70
- // The checkout-token route resolves intents and mints credentials through the
71
- // source-control service; wire it into the workflows module before serving.
72
- setSourceControl(integrations.sourceControl);
73
- setAgentToolMaterializationServices({
74
- catalogs: agentToolCatalogs,
75
- loadWorkspaceConnectionSnapshot,
76
- getIntegrationConnectionById
106
+ workflows: workflowsClient
107
+ },
108
+ webhookDeliverySource: options.webhookDeliverySource
77
109
  });
78
110
  const projectsModule = createProjectsModule({
79
- sourceControl: integrations.sourceControl
111
+ integrations: integrationsClient
80
112
  });
81
113
  const definitionsModule = createDefinitionsModule({
82
- sourceControl: integrations.sourceControl,
83
- agentToolSelectionCatalogs,
84
- loadWorkspaceConnectionSnapshot,
85
- getIntegrationConnectionById
114
+ projects: projectsClient,
115
+ integrations: integrationsClient
86
116
  });
87
- return [
88
- authModule,
117
+ const modules = [
118
+ emailChallengesModule,
119
+ createAuthModule({
120
+ workspaces: workspacesClient
121
+ }),
89
122
  workspacesModule,
90
- secretsModule,
91
- agentModule,
123
+ createSecretsModule(projectsClient),
124
+ createAgentModule({
125
+ secrets: secretsClient
126
+ }),
92
127
  integrations.module,
93
128
  projectsModule,
94
129
  definitionsModule,
95
- workflowsModule,
130
+ createWorkflowsModule({
131
+ annotations: annotationsClient,
132
+ agent: agentClient,
133
+ definitions: definitionsClient,
134
+ auth: authClient,
135
+ projects: projectsClient,
136
+ runners: runnersClient,
137
+ secrets: secretsClient,
138
+ integrations: integrationsClient
139
+ }),
96
140
  annotationsModule,
97
- runnersModule,
98
- logsModule,
99
- triggersModule,
141
+ createRunnersModule({
142
+ auth: authClient
143
+ }),
144
+ createLogsModule({
145
+ workflows: workflowsClient,
146
+ jobLeaseTokenTtlSeconds: durationToSeconds(authConfig.AUTH_JOB_LEASE_TOKEN_EXPIRES_IN)
147
+ }),
148
+ createTriggersModule({
149
+ workflows: workflowsClient
150
+ }),
100
151
  dispatcherModule
101
152
  ];
153
+ registerInterModulePresentations({
154
+ transport: interModuleTransport,
155
+ modules
156
+ });
157
+ interModuleTransport.seal();
158
+ return modules;
102
159
  }
103
160
 
104
161
  //# sourceMappingURL=modules.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/modules.ts"],"sourcesContent":["import {annotationsModule} from '@shipfox/annotations';\nimport {agentModule} from '@shipfox/api-agent';\nimport {authModule} from '@shipfox/api-auth';\nimport {createDefinitionsModule} from '@shipfox/api-definitions';\nimport {dispatcherModule} from '@shipfox/api-dispatcher';\nimport {\n buildAgentToolCatalogs,\n buildAgentToolSelectionCatalogs,\n createIntegrationsContext,\n createWorkspaceConnectionSnapshotLoader,\n getIntegrationConnectionById,\n} from '@shipfox/api-integration-core';\nimport {logsModule} from '@shipfox/api-logs';\nimport {createProjectsModule} from '@shipfox/api-projects';\nimport {runnersModule} from '@shipfox/api-runners';\nimport {deleteSecrets, getSecret, secretsModule, setSecrets} from '@shipfox/api-secrets';\nimport {triggersModule} from '@shipfox/api-triggers';\nimport {\n loadRunningLeasedStep,\n setAgentToolMaterializationServices,\n setSourceControl,\n workflowsModule,\n} from '@shipfox/api-workflows';\nimport {workspacesModule} from '@shipfox/api-workspaces';\nimport type {ShipfoxModule} from '@shipfox/node-module';\n\nexport async function defaultModules(): Promise<ShipfoxModule[]> {\n const integrations = await createIntegrationsContext({\n secrets: {\n deleteSecrets,\n linear: {\n getSecret: (params) =>\n getSecret({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n }),\n setSecrets: (params) =>\n setSecrets({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n }),\n deleteSecrets: (params) =>\n deleteSecrets({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n }),\n },\n jira: {\n getSecret: (params) =>\n getSecret({...params, namespace: `system/integrations/jira/${params.namespace}`}),\n setSecrets: (params) =>\n setSecrets({...params, namespace: `system/integrations/jira/${params.namespace}`}),\n deleteSecrets: (params) =>\n deleteSecrets({...params, namespace: `system/integrations/jira/${params.namespace}`}),\n },\n slack: {\n getSecret: (params) =>\n getSecret({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n }),\n setSecrets: (params) =>\n setSecrets({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n }),\n deleteSecrets: (params) =>\n deleteSecrets({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n }),\n },\n },\n agentTools: {loadLeasedAgentStep: loadRunningLeasedStep},\n });\n const [agentToolSelectionCatalogs, agentToolCatalogs] = await Promise.all([\n buildAgentToolSelectionCatalogs(integrations.registry),\n buildAgentToolCatalogs(integrations.registry),\n ]);\n const loadWorkspaceConnectionSnapshot = createWorkspaceConnectionSnapshotLoader(\n integrations.registry,\n );\n\n // The checkout-token route resolves intents and mints credentials through the\n // source-control service; wire it into the workflows module before serving.\n setSourceControl(integrations.sourceControl);\n setAgentToolMaterializationServices({\n catalogs: agentToolCatalogs,\n loadWorkspaceConnectionSnapshot,\n getIntegrationConnectionById,\n });\n const projectsModule = createProjectsModule({sourceControl: integrations.sourceControl});\n const definitionsModule = createDefinitionsModule({\n sourceControl: integrations.sourceControl,\n agentToolSelectionCatalogs,\n loadWorkspaceConnectionSnapshot,\n getIntegrationConnectionById,\n });\n\n return [\n authModule,\n workspacesModule,\n secretsModule,\n agentModule,\n integrations.module,\n projectsModule,\n definitionsModule,\n workflowsModule,\n annotationsModule,\n runnersModule,\n logsModule,\n triggersModule,\n dispatcherModule,\n ];\n}\n"],"names":["annotationsModule","agentModule","authModule","createDefinitionsModule","dispatcherModule","buildAgentToolCatalogs","buildAgentToolSelectionCatalogs","createIntegrationsContext","createWorkspaceConnectionSnapshotLoader","getIntegrationConnectionById","logsModule","createProjectsModule","runnersModule","deleteSecrets","getSecret","secretsModule","setSecrets","triggersModule","loadRunningLeasedStep","setAgentToolMaterializationServices","setSourceControl","workflowsModule","workspacesModule","defaultModules","integrations","secrets","linear","params","namespace","jira","slack","agentTools","loadLeasedAgentStep","agentToolSelectionCatalogs","agentToolCatalogs","Promise","all","registry","loadWorkspaceConnectionSnapshot","sourceControl","catalogs","projectsModule","definitionsModule","module"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,WAAW,QAAO,qBAAqB;AAC/C,SAAQC,UAAU,QAAO,oBAAoB;AAC7C,SAAQC,uBAAuB,QAAO,2BAA2B;AACjE,SAAQC,gBAAgB,QAAO,0BAA0B;AACzD,SACEC,sBAAsB,EACtBC,+BAA+B,EAC/BC,yBAAyB,EACzBC,uCAAuC,EACvCC,4BAA4B,QACvB,gCAAgC;AACvC,SAAQC,UAAU,QAAO,oBAAoB;AAC7C,SAAQC,oBAAoB,QAAO,wBAAwB;AAC3D,SAAQC,aAAa,QAAO,uBAAuB;AACnD,SAAQC,aAAa,EAAEC,SAAS,EAAEC,aAAa,EAAEC,UAAU,QAAO,uBAAuB;AACzF,SAAQC,cAAc,QAAO,wBAAwB;AACrD,SACEC,qBAAqB,EACrBC,mCAAmC,EACnCC,gBAAgB,EAChBC,eAAe,QACV,yBAAyB;AAChC,SAAQC,gBAAgB,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4BAA4BC,kBAAkB,GAAG,MAAMC,QAAQC,GAAG,CAAC;QACxE9B,gCAAgCkB,aAAaa,QAAQ;QACrDhC,uBAAuBmB,aAAaa,QAAQ;KAC7C;IACD,MAAMC,kCAAkC9B,wCACtCgB,aAAaa,QAAQ;IAGvB,8EAA8E;IAC9E,4EAA4E;IAC5EjB,iBAAiBI,aAAae,aAAa;IAC3CpB,oCAAoC;QAClCqB,UAAUN;QACVI;QACA7B;IACF;IACA,MAAMgC,iBAAiB9B,qBAAqB;QAAC4B,eAAef,aAAae,aAAa;IAAA;IACtF,MAAMG,oBAAoBvC,wBAAwB;QAChDoC,eAAef,aAAae,aAAa;QACzCN;QACAK;QACA7B;IACF;IAEA,OAAO;QACLP;QACAoB;QACAP;QACAd;QACAuB,aAAamB,MAAM;QACnBF;QACAC;QACArB;QACArB;QACAY;QACAF;QACAO;QACAb;KACD;AACH"}
1
+ {"version":3,"sources":["../src/modules.ts"],"sourcesContent":["import {annotationsModule} from '@shipfox/annotations';\nimport {annotationsInterModuleContract} from '@shipfox/annotations-dto/inter-module';\nimport {createAgentModule} from '@shipfox/api-agent';\nimport {agentInterModuleContract} from '@shipfox/api-agent-dto/inter-module';\nimport {createAuthModule} from '@shipfox/api-auth';\nimport {config as authConfig} from '@shipfox/api-auth/config';\nimport {authInterModuleContract} from '@shipfox/api-auth-dto/inter-module';\nimport {createDefinitionsModule} from '@shipfox/api-definitions';\nimport {definitionsInterModuleContract} from '@shipfox/api-definitions-dto/inter-module';\nimport {dispatcherModule} from '@shipfox/api-dispatcher';\nimport {emailChallengesModule} from '@shipfox/api-email-challenges';\nimport {createIntegrationsContext, type WebhookDeliverySource} from '@shipfox/api-integration-core';\nimport {integrationsInterModuleContract} from '@shipfox/api-integration-core-dto';\nimport {createLogsModule} from '@shipfox/api-logs';\nimport {createProjectsModule} from '@shipfox/api-projects';\nimport {projectsInterModuleContract} from '@shipfox/api-projects-dto';\nimport {createRunnersModule} from '@shipfox/api-runners';\nimport {runnersInterModuleContract} from '@shipfox/api-runners-dto/inter-module';\nimport {createSecretsModule} from '@shipfox/api-secrets';\nimport {secretsInterModuleContract} from '@shipfox/api-secrets-dto/inter-module';\nimport {createTriggersModule} from '@shipfox/api-triggers';\nimport {createWorkflowsModule} from '@shipfox/api-workflows';\nimport {workflowsInterModuleContract} from '@shipfox/api-workflows-dto/inter-module';\nimport {workspacesModule} from '@shipfox/api-workspaces';\nimport {workspacesInterModuleContract} from '@shipfox/api-workspaces-dto/inter-module';\nimport {durationToSeconds} from '@shipfox/node-jwt';\nimport type {ShipfoxModule} from '@shipfox/node-module';\nimport {\n createInMemoryInterModuleTransport,\n registerInterModulePresentations,\n} from '@shipfox/node-module/inter-module';\n\nexport interface DefaultModulesOptions {\n webhookDeliverySource?: WebhookDeliverySource | undefined;\n}\n\nexport async function defaultModules(\n options: DefaultModulesOptions = {},\n): Promise<ShipfoxModule[]> {\n const interModuleTransport = createInMemoryInterModuleTransport();\n const workflowsClient = interModuleTransport.createClient(workflowsInterModuleContract);\n const authClient = interModuleTransport.createClient(authInterModuleContract);\n const agentClient = interModuleTransport.createClient(agentInterModuleContract);\n const runnersClient = interModuleTransport.createClient(runnersInterModuleContract);\n const projectsClient = interModuleTransport.createClient(projectsInterModuleContract);\n const definitionsClient = interModuleTransport.createClient(definitionsInterModuleContract);\n const annotationsClient = interModuleTransport.createClient(annotationsInterModuleContract);\n const secretsClient = interModuleTransport.createClient(secretsInterModuleContract);\n const workspacesClient = interModuleTransport.createClient(workspacesInterModuleContract);\n const integrationsClient = interModuleTransport.createClient(integrationsInterModuleContract);\n const integrations = await createIntegrationsContext({\n workspaces: workspacesClient,\n secrets: {\n deleteSecrets: async (params) => (await secretsClient.deleteSecrets(params)).deleted,\n linear: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/linear/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/linear/${params.namespace}`,\n })\n ).deleted,\n },\n jira: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/jira/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/jira/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/jira/${params.namespace}`,\n })\n ).deleted,\n },\n slack: {\n getSecret: async (params) =>\n (\n await secretsClient.getSecret({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n })\n ).value,\n setSecrets: async (params) => {\n const {editedBy, ...secretParams} = params;\n await secretsClient.setSecrets({\n ...secretParams,\n namespace: `system/integrations/slack/${secretParams.namespace}`,\n ...(editedBy === undefined ? {} : {editedBy}),\n });\n },\n deleteSecrets: async (params) =>\n (\n await secretsClient.deleteSecrets({\n ...params,\n namespace: `system/integrations/slack/${params.namespace}`,\n })\n ).deleted,\n },\n },\n agentTools: {workflows: workflowsClient},\n webhookDeliverySource: options.webhookDeliverySource,\n });\n const projectsModule = createProjectsModule({integrations: integrationsClient});\n const definitionsModule = createDefinitionsModule({\n projects: projectsClient,\n integrations: integrationsClient,\n });\n\n const modules = [\n emailChallengesModule,\n createAuthModule({workspaces: workspacesClient}),\n workspacesModule,\n createSecretsModule(projectsClient),\n createAgentModule({secrets: secretsClient}),\n integrations.module,\n projectsModule,\n definitionsModule,\n createWorkflowsModule({\n annotations: annotationsClient,\n agent: agentClient,\n definitions: definitionsClient,\n auth: authClient,\n projects: projectsClient,\n runners: runnersClient,\n secrets: secretsClient,\n integrations: integrationsClient,\n }),\n annotationsModule,\n createRunnersModule({auth: authClient}),\n createLogsModule({\n workflows: workflowsClient,\n jobLeaseTokenTtlSeconds: durationToSeconds(authConfig.AUTH_JOB_LEASE_TOKEN_EXPIRES_IN),\n }),\n createTriggersModule({workflows: workflowsClient}),\n dispatcherModule,\n ];\n registerInterModulePresentations({transport: interModuleTransport, modules});\n interModuleTransport.seal();\n return modules;\n}\n"],"names":["annotationsModule","annotationsInterModuleContract","createAgentModule","agentInterModuleContract","createAuthModule","config","authConfig","authInterModuleContract","createDefinitionsModule","definitionsInterModuleContract","dispatcherModule","emailChallengesModule","createIntegrationsContext","integrationsInterModuleContract","createLogsModule","createProjectsModule","projectsInterModuleContract","createRunnersModule","runnersInterModuleContract","createSecretsModule","secretsInterModuleContract","createTriggersModule","createWorkflowsModule","workflowsInterModuleContract","workspacesModule","workspacesInterModuleContract","durationToSeconds","createInMemoryInterModuleTransport","registerInterModulePresentations","defaultModules","options","interModuleTransport","workflowsClient","createClient","authClient","agentClient","runnersClient","projectsClient","definitionsClient","annotationsClient","secretsClient","workspacesClient","integrationsClient","integrations","workspaces","secrets","deleteSecrets","params","deleted","linear","getSecret","namespace","value","setSecrets","editedBy","secretParams","undefined","jira","slack","agentTools","workflows","webhookDeliverySource","projectsModule","definitionsModule","projects","modules","module","annotations","agent","definitions","auth","runners","jobLeaseTokenTtlSeconds","AUTH_JOB_LEASE_TOKEN_EXPIRES_IN","transport","seal"],"mappings":"AAAA,SAAQA,iBAAiB,QAAO,uBAAuB;AACvD,SAAQC,8BAA8B,QAAO,wCAAwC;AACrF,SAAQC,iBAAiB,QAAO,qBAAqB;AACrD,SAAQC,wBAAwB,QAAO,sCAAsC;AAC7E,SAAQC,gBAAgB,QAAO,oBAAoB;AACnD,SAAQC,UAAUC,UAAU,QAAO,2BAA2B;AAC9D,SAAQC,uBAAuB,QAAO,qCAAqC;AAC3E,SAAQC,uBAAuB,QAAO,2BAA2B;AACjE,SAAQC,8BAA8B,QAAO,4CAA4C;A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;QACA1C;QACAiB,oBAAoB;YAACqD,MAAMpC;QAAU;QACrCpB,iBAAiB;YACf8C,WAAW5B;YACXwC,yBAAyB9C,kBAAkBpB,WAAWmE,+BAA+B;QACvF;QACApD,qBAAqB;YAACuC,WAAW5B;QAAe;QAChDtB;KACD;IACDkB,iCAAiC;QAAC8C,WAAW3C;QAAsBkC;IAAO;IAC1ElC,qBAAqB4C,IAAI;IACzB,OAAOV;AACT"}
package/dist/server.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { type ModuleWorker, type ShipfoxModule } from '@shipfox/node-module';
1
+ import { type ModuleService, type ModuleWorker, type ShipfoxModule } from '@shipfox/node-module';
2
2
  export interface CreateServerOptions {
3
3
  modules: ShipfoxModule[];
4
4
  onWorkerFailure?: (error: unknown, worker: ModuleWorker) => void | Promise<void>;
5
+ onServiceFailure?: (error: unknown, service: ModuleService) => void | Promise<void>;
5
6
  }
6
7
  export interface ServerHandle {
7
8
  start(): Promise<string>;
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,YAAY,EAMjB,KAAK,aAAa,EAEnB,MAAM,sBAAsB,CAAC;AAW9B,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAClF;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CA4FtF;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAgChF"}
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAEA,OAAO,EAGL,KAAK,aAAa,EAElB,KAAK,YAAY,EAIjB,KAAK,aAAa,EAGnB,MAAM,sBAAsB,CAAC;AAW9B,MAAM,WAAW,mBAAmB;IAClC,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,eAAe,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACjF,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,aAAa,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrF;AAED,MAAM,WAAW,YAAY;IAC3B,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACvB;AAED,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,aAAa,EAAE,CAAC;IACzB,gBAAgB,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAC7D;AAED,wBAAsB,YAAY,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,YAAY,CAAC,CAuGtF;AAED,wBAAsB,SAAS,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAiChF"}
package/dist/server.js CHANGED
@@ -1,11 +1,11 @@
1
1
  import { captureException, closeErrorMonitoring } from '@shipfox/node-error-monitoring';
2
2
  import { closeApp, createApp, listen } from '@shipfox/node-fastify';
3
- import { aggregateLoginMethods, initializeModules, registerModuleMetrics, resetPublishers, resetSubscribers, runModuleStartupTasks, startModuleWorkers } from '@shipfox/node-module';
3
+ import { aggregateLoginMethods, initializeModules, registerModuleMetrics, runModuleStartupTasks, startModuleServices, startModuleWorkers } from '@shipfox/node-module';
4
4
  import { logger, shutdownServiceMetrics, startServiceMetrics } from '@shipfox/node-opentelemetry';
5
5
  import { closePostgresClient, createPostgresClient } from '@shipfox/node-postgres';
6
6
  import { config, parseApiTrustProxy } from './config.js';
7
7
  import { createE2eAdminAuthMethod, createE2eRouteGroup } from './e2e.js';
8
- const WORKER_FAILURE_HTTP_SHUTDOWN_TIMEOUT_MS = 10_000;
8
+ const RUNTIME_FAILURE_HTTP_SHUTDOWN_TIMEOUT_MS = 10_000;
9
9
  const ERROR_MONITORING_SHUTDOWN_TIMEOUT_MS = 2_000;
10
10
  let hasActiveServer = false;
11
11
  export async function createServer(options) {
@@ -21,14 +21,20 @@ export async function createServer(options) {
21
21
  serviceName: 'api'
22
22
  });
23
23
  createPostgresClient();
24
- const { auth, routes, e2eRoutes, workers } = await initializeModules({
24
+ const { auth, routes, e2eRoutes, workers, services, outboxRegistry } = await initializeModules({
25
25
  modules: options.modules
26
26
  });
27
27
  registerModuleMetrics({
28
- modules: options.modules
28
+ modules: options.modules,
29
+ context: {
30
+ outboxRegistry
31
+ }
29
32
  });
30
33
  await runModuleStartupTasks({
31
- modules: options.modules
34
+ modules: options.modules,
35
+ context: {
36
+ outboxRegistry
37
+ }
32
38
  });
33
39
  const e2eAuth = config.E2E_ENABLED ? [
34
40
  createE2eAdminAuthMethod(config)
@@ -49,6 +55,7 @@ export async function createServer(options) {
49
55
  }
50
56
  });
51
57
  let workersHandle;
58
+ let servicesHandle;
52
59
  let startPromise;
53
60
  let stopPromise;
54
61
  let stopped = false;
@@ -58,8 +65,19 @@ export async function createServer(options) {
58
65
  logger().info('Starting module workers');
59
66
  workersHandle = await startModuleWorkers({
60
67
  workers,
68
+ context: {
69
+ outboxRegistry
70
+ },
61
71
  onWorkerFailure: (error, worker)=>handleModuleWorkerFailure(error, worker, options.onWorkerFailure)
62
72
  });
73
+ logger().info('Starting module services');
74
+ servicesHandle = await startModuleServices({
75
+ services,
76
+ context: {
77
+ outboxRegistry
78
+ },
79
+ onServiceFailure: (error, service)=>handleModuleServiceFailure(error, service, options.onServiceFailure)
80
+ });
63
81
  if (stopPromise) throw new Error('API server stopped during startup');
64
82
  logger().info('Starting HTTP server');
65
83
  const address = config.API_PORT === undefined ? await listen() : await listen({
@@ -79,12 +97,13 @@ export async function createServer(options) {
79
97
  await startPromise?.catch(()=>undefined);
80
98
  const cleanupErrors = await runCleanupSteps([
81
99
  ()=>closeApp(),
100
+ ()=>servicesHandle?.stop(),
82
101
  ()=>workersHandle?.stop(),
83
102
  ()=>shutdownServiceMetrics(),
84
103
  ()=>closePostgresClient(),
85
- ()=>resetPublishers(),
86
- ()=>resetSubscribers(),
87
- ()=>closeErrorMonitoring(ERROR_MONITORING_SHUTDOWN_TIMEOUT_MS)
104
+ async ()=>{
105
+ await closeErrorMonitoring(ERROR_MONITORING_SHUTDOWN_TIMEOUT_MS);
106
+ }
88
107
  ]);
89
108
  throwCleanupErrors(cleanupErrors, 'Failed to stop API server');
90
109
  stopped = true;
@@ -102,9 +121,7 @@ export async function createServer(options) {
102
121
  } catch (error) {
103
122
  const cleanupErrors = await runCleanupSteps([
104
123
  ()=>shutdownServiceMetrics(),
105
- ()=>closePostgresClient(),
106
- ()=>resetPublishers(),
107
- ()=>resetSubscribers()
124
+ ()=>closePostgresClient()
108
125
  ]);
109
126
  for (const cleanupError of cleanupErrors){
110
127
  logger().error({
@@ -121,7 +138,8 @@ export async function runServer(options) {
121
138
  try {
122
139
  handle = await createServer({
123
140
  modules: options.modules,
124
- onWorkerFailure: ()=>process.exit(1)
141
+ onWorkerFailure: ()=>process.exit(1),
142
+ onServiceFailure: ()=>process.exit(1)
125
143
  });
126
144
  } catch (error) {
127
145
  await reportStartupFailure(error, options.onStartupFailure);
@@ -173,22 +191,42 @@ function throwCleanupErrors(cleanupErrors, message) {
173
191
  throw new AggregateError(cleanupErrors, message);
174
192
  }
175
193
  async function handleModuleWorkerFailure(error, worker, onWorkerFailure) {
194
+ await handleModuleRuntimeFailure({
195
+ error,
196
+ fields: {
197
+ taskQueue: worker.taskQueue
198
+ },
199
+ message: 'Module worker stopped unexpectedly',
200
+ onFailure: ()=>onWorkerFailure?.(error, worker)
201
+ });
202
+ }
203
+ async function handleModuleServiceFailure(error, service, onServiceFailure) {
204
+ await handleModuleRuntimeFailure({
205
+ error,
206
+ fields: {
207
+ service: service.name
208
+ },
209
+ message: 'Module service stopped unexpectedly',
210
+ onFailure: ()=>onServiceFailure?.(error, service)
211
+ });
212
+ }
213
+ async function handleModuleRuntimeFailure(options) {
176
214
  logger().error({
177
- err: error,
178
- taskQueue: worker.taskQueue
179
- }, 'Module worker stopped unexpectedly');
180
- captureException(error);
215
+ err: options.error,
216
+ ...options.fields
217
+ }, options.message);
218
+ captureException(options.error);
181
219
  try {
182
- await closeHttpServerAfterWorkerFailure();
220
+ await closeHttpServerAfterRuntimeFailure();
183
221
  await closeErrorMonitoring(ERROR_MONITORING_SHUTDOWN_TIMEOUT_MS);
184
222
  } finally{
185
- await onWorkerFailure?.(error, worker);
223
+ await options.onFailure();
186
224
  }
187
225
  }
188
- async function closeHttpServerAfterWorkerFailure() {
226
+ async function closeHttpServerAfterRuntimeFailure() {
189
227
  let timeoutId;
190
228
  const timeout = new Promise((resolve)=>{
191
- timeoutId = setTimeout(()=>resolve('timeout'), WORKER_FAILURE_HTTP_SHUTDOWN_TIMEOUT_MS);
229
+ timeoutId = setTimeout(()=>resolve('timeout'), RUNTIME_FAILURE_HTTP_SHUTDOWN_TIMEOUT_MS);
192
230
  });
193
231
  try {
194
232
  const result = await Promise.race([
@@ -201,13 +239,13 @@ async function closeHttpServerAfterWorkerFailure() {
201
239
  });
202
240
  if (result === 'timeout') {
203
241
  logger().error({
204
- timeoutMs: WORKER_FAILURE_HTTP_SHUTDOWN_TIMEOUT_MS
205
- }, 'Timed out closing HTTP server after worker failure');
242
+ timeoutMs: RUNTIME_FAILURE_HTTP_SHUTDOWN_TIMEOUT_MS
243
+ }, 'Timed out closing HTTP server after module runtime failure');
206
244
  }
207
245
  } catch (error) {
208
246
  logger().error({
209
247
  err: error
210
- }, 'Failed to close HTTP server after worker failure');
248
+ }, 'Failed to close HTTP server after module runtime failure');
211
249
  } finally{
212
250
  if (timeoutId) {
213
251
  clearTimeout(timeoutId);