From 929b55ee0d97e6adbc5e12bbdc45cfb996728aa2 Mon Sep 17 00:00:00 2001 From: andypalmi Date: Fri, 2 Oct 2026 12:03:05 +0200 Subject: [PATCH] Await file requests so launcher errors keep their status code The static file functions returned the got promise from inside a try block, so rejections bypassed the catch and the status code was never set on the error. Await the requests and read the status code with optional chaining so errors without a response are passed through unchanged. --- docker.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/docker.js b/docker.js index dd953ce..e921029 100644 --- a/docker.js +++ b/docker.js @@ -788,9 +788,9 @@ module.exports = { listFiles: async (instance, filePath) => { const fileUrl = await getStaticFileUrl(instance, filePath) try { - return got.get(fileUrl).json() + return await got.get(fileUrl).json() } catch (err) { - err.statusCode = err.response.statusCode + err.statusCode = err.response?.statusCode throw err } }, @@ -798,11 +798,11 @@ module.exports = { updateFile: async (instance, filePath, update) => { const fileUrl = await getStaticFileUrl(instance, filePath) try { - return got.put(fileUrl, { + return await got.put(fileUrl, { json: update }) } catch (err) { - err.statusCode = err.response.statusCode + err.statusCode = err.response?.statusCode throw err } }, @@ -810,20 +810,20 @@ module.exports = { deleteFile: async (instance, filePath) => { const fileUrl = await getStaticFileUrl(instance, filePath) try { - return got.delete(fileUrl) + return await got.delete(fileUrl) } catch (err) { - err.statusCode = err.response.statusCode + err.statusCode = err.response?.statusCode throw err } }, createDirectory: async (instance, filePath, directoryName) => { const fileUrl = await getStaticFileUrl(instance, filePath) try { - return got.post(fileUrl, { + return await got.post(fileUrl, { json: { path: directoryName } }) } catch (err) { - err.statusCode = err.response.statusCode + err.statusCode = err.response?.statusCode throw err } }, @@ -832,11 +832,11 @@ module.exports = { form.append('file', fileBuffer, { filename: filePath }) const fileUrl = await getStaticFileUrl(instance, filePath) try { - return got.post(fileUrl, { + return await got.post(fileUrl, { body: form }) } catch (err) { - err.statusCode = err.response.statusCode + err.statusCode = err.response?.statusCode throw err } },