首页 > 解决方案 > 错误:下载 deno 导入时出现 429 Too Many Requests

问题描述

我正在将 deno 与 dockerhayd/alpine-deno映像一起使用并denon监视文件更改。当我构建容器时,我会429 Too Many Requests导入std依赖项:

...

Download https://deno.land/std@0.54.0/encoding/_yaml/type/int.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/map.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/merge.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/nil.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/omap.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/pairs.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/seq.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/set.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/str.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/timestamp.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/binary.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/bool.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/float.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/int.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/map.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/merge.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/nil.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/omap.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/pairs.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/seq.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/set.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/str.ts

Download https://deno.land/std@0.54.0/encoding/_yaml/type/timestamp.ts

error: Import 'https://deno.land/std@0.54.0/encoding/_yaml/type/timestamp.ts' failed: 429 Too Many Requests

我的外部依赖项在deps.ts其中具有以下导入:

export { Application, Router } from 'https://deno.land/x/oak/mod.ts'
export { connect } from 'https://deno.land/x/redis/mod.ts'

除了 denon 导入之外,没有其他外部依赖项。

我用来运行它的 Dockerfile:

FROM hayd/alpine-deno:1.0.1

ENV DENO_DIR /cache

EXPOSE 4000

WORKDIR /app/

COPY . .

RUN deno install --allow-read --allow-run --allow-write -f --unstable https://deno.land/x/denon/denon.ts
RUN deno cache src/deps.ts

ENTRYPOINT ["/root/.deno/bin/denon"]

CMD ["run", "--allow-net", "src/mod.ts"]

似乎许多文件被多次下载(或尝试下载、失败并重试)。这并不总是发生,但经常足以破坏构建自动化。有没有人有类似的问题?缓存导入是否有问题?

标签: dockerdeno

解决方案


缓存导入是否有问题?

不,缓存与它无关。

它似乎deno.land有速率限制,并且您超出了这些限制。您可以做的是直接使用 github,这很可能会有更高的限制。

供天龙使用

https://raw.githubusercontent.com/denosaurs/denon/master/denon.ts

您还可以更改代码依赖项:

改变https://deno.land/x/oak/mod.ts_https://raw.githubusercontent.com/oakserver/oak/master/mod.ts

redis你应该使用https://raw.githubusercontent.com/keroxp/deno-redis/master/mod.ts

https://deno.land/x只不过是一个 URL 重写服务器,所以最后,你实际上是从 Github 中提取的。

deno.land/x 是 Deno 脚本的 URL 重写服务。代码 URL 的基本格式是 https://deno.land/x/MODULE_NAME@BRANCH/SCRIPT.ts。如果省略分支,它将默认为模块的默认分支,通常是 master。


您应该使用标记版本,master否则您的 docker 映像将不会始终具有相同的 Oak 代码。

为了v4.0.0

export { Application, Router } from 'https://github.com/oakserver/oak/blob/v4.0.0/mod.ts'
export { connect } from 'https://raw.githubusercontent.com/keroxp/deno-redis/v0.10.1/mod.ts

推荐阅读