【问题标题】:Error: 429 Too Many Requests while downloading deno imports错误:下载 deno 导入时出现 429 Too Many Requests
【发布时间】:2020-09-27 08:59:15
【问题描述】:

我将 deno 与 docker hayd/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"]

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

【问题讨论】:

    标签: docker deno


    【解决方案1】:

    缓存导入有问题吗?

    不,缓存与它无关。

    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 否则您的 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
    

    【讨论】:

    • 谢谢。尽管某些依赖项仍然从 deno.land 导入,但更改我自己的导入似乎足以解决目前的限制问题。
    【解决方案2】:

    Deno 包管理器,相当新。我查了一下,Deno 团队仍在进行优化。

    使用鼠兔,更好的支持。

    https://www.pika.dev/docs/

    或者:

    https://denopkg.com/

    denopkg 样本:

    import { opn } from 'https://denopkg.com/hashrock/deno-opn/opn.ts'
    
    opn('https://denopkg.com')
    

    【讨论】:

      猜你喜欢
      • 2021-12-31
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-08-06
      • 2021-08-14
      • 1970-01-01
      • 2021-12-13
      • 1970-01-01
      相关资源
      最近更新 更多