Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/js-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"knip": "^5.43.6",
"npm-check-updates": "^16.14.20",
"npm-run-all": "^4.1.5",
"openapi-typescript": "^7.6.1",
"openapi-typescript": "^7.9.1",
"playwright": "^1.48.0",
"react": "^18.3.1",
"tsup": "^8.4.0",
Expand Down Expand Up @@ -92,7 +92,7 @@
"compare-versions": "^6.1.0",
"dockerfile-ast": "^0.7.1",
"glob": "^11.0.3",
"openapi-fetch": "^0.9.7",
"openapi-fetch": "^0.14.1",
"platform": "^1.3.6",
"tar": "^7.4.3"
},
Expand Down
10 changes: 6 additions & 4 deletions packages/js-sdk/src/envd/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,19 @@
import { Code, ConnectError } from '@connectrpc/connect'
import { WatchDirResponse } from './filesystem/filesystem_pb'

export async function handleEnvdApiError<A, B, C extends `${string}/${string}`>(
res: FetchResponse<A, B, C>
) {
export async function handleEnvdApiError<
A extends { responses: Record<string, any> },
B,
C extends `${string}/${string}`
>(res: FetchResponse<A, B, C>) {
if (!res.error) {
return
}

const message: string =
typeof res.error == 'string'
? res.error
: res.error?.message || (await res.response.text())
: (res.error as any)?.message || (await res.response.text())

switch (res.response.status) {
case 400:
Expand All @@ -43,7 +45,7 @@
case 507:
return new NotEnoughSpaceError(message)
default:
return new SandboxError(`${res.response.status}: ${message}`)

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/read.test.ts > read file

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/read.test.ts:10:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/list.test.ts > mixed entries (files and directories)

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/list.test.ts:176:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/list.test.ts > file entry details

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/list.test.ts:129:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/list.test.ts > list directory

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/list.test.ts:16:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/info.test.ts > get info of a symlink

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/info.test.ts:60:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/info.test.ts > get info of a file

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/info.test.ts:10:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/files/exists.test.ts > file exists

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/files/exists.test.ts:8:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/snapshot.test.ts > pause and resume a sandbox with file

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/snapshot.test.ts:59:18

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/secure.test.ts > try to re-connect to sandbox

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/secure.test.ts:34:3

Check failure on line 48 in packages/js-sdk/src/envd/api.ts

View workflow job for this annotation

GitHub Actions / JS SDK - Build and test

tests/sandbox/secure.test.ts > test access file with signing

SandboxError: 500: error parsing multipart form: no multipart boundary param in Content-Type ❯ handleEnvdApiError src/envd/api.ts:48:14 ❯ Filesystem.write src/sandbox/filesystem/index.ts:375:23 ❯ tests/sandbox/secure.test.ts:13:3
}
}

Expand Down
17 changes: 8 additions & 9 deletions packages/js-sdk/src/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,18 @@ export function createRpcLogger(logger: Logger): Interceptor {

export function createApiLogger(logger: Logger): Middleware {
return {
async onRequest(req) {
logger.info?.(`Request ${req.method} ${req.url}`)

return req
async onRequest({ request }) {
logger.info?.(`Request ${request.method} ${request.url}`)
return request
},
async onResponse(res) {
if (res.status >= 400) {
logger.error?.('Response:', res.status, res.statusText)
async onResponse({ response }) {
if (response.status >= 400) {
logger.error?.('Response:', response.status, response.statusText)
} else {
logger.info?.('Response:', res.status, res.statusText)
logger.info?.('Response:', response.status, response.statusText)
}

return res
return response
},
}
}
Loading
Loading