Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fetch error due to header get failed #239

Merged
merged 1 commit into from
Mar 2, 2024
Merged
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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"generate"
],
"peerDependencies": {
"koishi": "^4.16.8"
"koishi": "^4.17.0-alpha.0"
},
"devDependencies": {
"@cordisjs/vitepress": "^3.2.6",
Expand All @@ -73,7 +73,7 @@
"@types/libsodium-wrappers-sumo": "^0.7.8",
"@types/node": "^20.11.19",
"atsc": "^1.2.2",
"koishi": "^4.16.8",
"koishi": "^4.17.0",
"sass": "^1.71.0",
"typescript": "^5.3.3",
"vitepress": "1.0.0-rc.40"
Expand Down
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
return session.text('.unauthorized')
} else if (err.response?.status) {
return session.text('.response-error', [err.response.status])
} else if (err.code === 'ETIMEDOUT') {

Check failure on line 22 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.

Check failure on line 22 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.
return session.text('.request-timeout')
} else if (err.code) {

Check failure on line 24 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.

Check failure on line 24 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.
return session.text('.request-failed', [err.code])

Check failure on line 25 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.

Check failure on line 25 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.
}
}
logger.error(err)
Expand Down Expand Up @@ -441,13 +441,13 @@
}
const imgRes = await ctx.http.axios(imgUrl, { responseType: 'arraybuffer' })
const b64 = Buffer.from(imgRes.data).toString('base64')
return forceDataPrefix(b64, imgRes.headers['content-type'])
return forceDataPrefix(b64, imgRes.headers.get('content-type'))
}
// event: newImage
// id: 1
// data:

if (res.headers['content-type'] === 'application/x-zip-compressed') {
if (res.headers.get('content-type') === 'application/x-zip-compressed') {
const buffer = Buffer.from(res.data, 'binary') // Ensure 'binary' encoding
const zip = new AdmZip(buffer)

Expand All @@ -468,7 +468,7 @@
break
} catch (err) {
if (Quester.isAxiosError(err)) {
if (err.code && err.code !== 'ETIMEDOUT' && ++count < config.maxRetryCount) {

Check failure on line 471 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.

Check failure on line 471 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.

Check failure on line 471 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.

Check failure on line 471 in src/index.ts

View workflow job for this annotation

GitHub Actions / build

Property 'code' does not exist on type 'HTTPError'.
continue
}
}
Expand Down
Loading