@empyria/restate 0.4.6 → 0.4.7

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/lib/Admin.js CHANGED
@@ -157,7 +157,8 @@ export async function queryRestate({ restateAdminURL, sql }) {
157
157
  }
158
158
 
159
159
  /**
160
- * Force-deletes a deployment from Restate, draining any in-flight invocations.
160
+ * Force-deletes a deployment from Restate, draining any in-flight invocations. A deployment Restate no
161
+ * longer knows (404) counts as deleted: the goal is that it is gone, so the call is safe to repeat.
161
162
  * @param {string} restateAdminURL
162
163
  * @param {string} deploymentId
163
164
  * @returns {Promise<void>}
@@ -166,7 +167,7 @@ export async function deleteDeployment(restateAdminURL, deploymentId) {
166
167
  const response = await fetch(`${restateAdminURL}/deployments/${deploymentId}?force=true`, {
167
168
  method: 'DELETE',
168
169
  })
169
- if (!response.ok) {
170
+ if (!response.ok && response.status !== 404) {
170
171
  throw new restate.TerminalError(
171
172
  `Failed to delete deployment: ${response.status} ${response.statusText}`,
172
173
  { errorCode: ERROR_INFRASTRUCTURE },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@empyria/restate",
3
- "version": "0.4.6",
3
+ "version": "0.4.7",
4
4
  "description": "Restate.dev helpers for the Empyria nanoservice framework",
5
5
  "license": "MIT",
6
6
  "author": "Imre Fazekas <imre.fazekas@icloud.com>",
@@ -229,6 +229,11 @@ describe('deleteDeployment', () => {
229
229
  await expect(deleteDeployment('http://admin', 'dep-1')).resolves.toBeUndefined()
230
230
  })
231
231
 
232
+ test('treats an unknown deployment (404) as already deleted', async () => {
233
+ globalThis.fetch = mock(async () => jsonResponse(null, false, 404))
234
+ await expect(deleteDeployment('http://admin', 'dep-1')).resolves.toBeUndefined()
235
+ })
236
+
232
237
  test('throws on failure', async () => {
233
238
  globalThis.fetch = mock(async () => jsonResponse(null, false))
234
239
  await expect(deleteDeployment('http://admin', 'dep-1')).rejects.toThrow(