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: retry gateway denly list kv get #50

Merged
merged 2 commits into from
Apr 22, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/edge-gateway/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"nanoid": "^3.1.30",
"p-any": "^4.0.0",
"p-map": "^5.3.0",
"p-retry": "^5.0.0",
"p-settle": "^5.0.0",
"p-some": "^5.0.0",
"toucan-js": "^2.5.0",
Expand All @@ -41,7 +42,6 @@
"ipfs-utils": "^9.0.4",
"miniflare": "^2.2.0",
"npm-run-all": "^4.1.5",
"p-retry": "^5.0.0",
"p-wait-for": "^4.1.0",
"sade": "^1.7.4",
"smoke": "^3.1.1",
Expand Down
13 changes: 10 additions & 3 deletions packages/edge-gateway/src/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import pAny, { AggregateError } from 'p-any'
import { FilterError } from 'p-some'
import pSettle from 'p-settle'
import pRetry from 'p-retry'

import { TimeoutError } from './errors.js'
import { getCidFromSubdomainUrl } from './utils/cid.js'
Expand Down Expand Up @@ -53,9 +54,15 @@ export async function gatewayGet(request, env, ctx) {

if (env.DENYLIST) {
const anchor = await toDenyListAnchor(cid)
// TODO: in theory we should check each subcomponent of the pathname also.
// https://github.com/nftstorage/nft.storage/issues/1737
const value = await env.DENYLIST.get(anchor)
// TODO: Remove once CF team as a solution for "Network connection lost" Errors
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, would be good to cite an issue here with more context.

vasco-santos marked this conversation as resolved.
Show resolved Hide resolved
const value = await pRetry(
// TODO: in theory we should check each subcomponent of the pathname also.
// https://github.com/nftstorage/nft.storage/issues/1737
() => env.DENYLIST.get(anchor),
{ retries: 5 }
)

// const value = await env.DENYLIST.get(anchor)
if (value) {
const { status, reason } = JSON.parse(value)
return new Response(reason || '', { status: status || 410 })
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.