Code Monkey home page Code Monkey logo

cnpmweb's Issues

[Bug Report]: 点击版本选项卡后,会发生过滤页面数据异常

重现步骤:

  1. https://npmmirror.com/package/czg/home 首页点击 “查看全部” 版本
  2. 我的这个包有一些 beta 版本号,在点击 “版本记录” - “所有版本” & “当前 Tags” - “所有版本” 后出现列表闪动,列表从正常的显示数据变化为错误的显示数据
  3. url query param 正常发生变化 ?versions=all&tags=all

初步怀疑是列表过滤与 url props 的改变进行渲染碰撞导致


CleanShot.2023-12-19.at.10.30.37-converted.mp4

Originally posted by @Zhengqbbb in #63 (comment)

[非技术问题]建议做一个年度下载量总结

建议做一个 2023 年度不同 Npm 的下载量总结,看看排行排前几的在载量,方便让更多人尝试分析国内用户的使用偏好和技术发展趋势

比如我想知道,下载量排行前 100 的 npm 下载有哪些,yearly downloads,增长趋势如何。

手动同步按钮无效,点击后看日志没获取到最近版本,也没有同步. 但是cnpm sync有效.

手动同步按钮无效的日志如下:

[2023-08-22T09:24:30.930Z] 👉👉👉👉👉 Tips: Sync cause by "http://registry.npmmirror.com/-/package/webcmp-topo-chart-horizontal/syncs", parent traceId: b2cd0cc0-40cd-11ee-a4f1-c763c5ab955e 👈👈👈👈👈
[2023-08-22T09:24:30.931Z] 🚧🚧🚧🚧🚧 Syncing from https://r.cnpmjs.org/webcmp-topo-chart-horizontal, skipDependencies: false, syncUpstream: true, syncDownloadData: false, forceSyncHistory: false attempts: 1, worker: "npmmirror-x86-2022012802003/605336", taskQueue: 0/100 🚧🚧🚧🚧🚧
[2023-08-22T09:24:30.931Z] 🚧 log: https://registry.npmmirror.com/-/package/webcmp-topo-chart-horizontal/syncs/64e47ecedb64f94e007b8b27/log
[2023-08-22T09:24:33.226Z] HTTP [200] content-length: -, timing: {"queuing":0.083,"connected":805.457,"requestHeadersSent":805.492,"requestSent":805.543,"waiting":1840.592,"contentDownload":2291.072}
[2023-08-22T09:24:33.226Z] 📖 webcmp-topo-chart-horizontal latest version: 3.2.5, published time: "2023-08-22T08:19:16.051Z"
[2023-08-22T09:24:33.226Z] 🚧 Syncing maintainers: [{"name":"ymrdf","email":"[email protected]"},{"name":"xishu-tech","email":"[email protected]"}]
[2023-08-22T09:24:33.396Z] 🚧 Syncing versions 68 => 68
[2023-08-22T09:24:33.396Z] 🟢 Synced updated 0 versions, removed 0 versions
[2023-08-22T09:24:33.416Z] 🗑️ Clean cache
[2023-08-22T09:24:33.416Z] 📝 Log URL: https://registry.npmmirror.com/-/package/webcmp-topo-chart-horizontal/syncs/64e47ecedb64f94e007b8b27/log
[2023-08-22T09:24:33.416Z] 🔗 https://r.cnpmjs.org/webcmp-topo-chart-horizontal?t=1692696270931&cache=0

cnpm sync的日志如下:

[2023-08-22T09:26:15.786Z] 👉👉👉👉👉 Tips: Sync cause by "http://registry-direct.npmmirror.com/webcmp-topo-chart-horizontal/sync?publish=false&nodeps=false", parent traceId: f16426d0-40cd-11ee-8212-8955926d8e04 👈👈👈👈👈
[2023-08-22T09:26:15.786Z] 🚧🚧🚧🚧🚧 Syncing from https://r.cnpmjs.org/webcmp-topo-chart-horizontal, skipDependencies: false, syncUpstream: true, syncDownloadData: false, forceSyncHistory: false attempts: 1, worker: "npmmirror-x86-2022012802003/605339", taskQueue: 0/100 🚧🚧🚧🚧🚧
[2023-08-22T09:26:15.786Z] 🚧 log: https://registry.npmmirror.com/-/package/webcmp-topo-chart-horizontal/syncs/64e47f37f3ded62aa4fff71a/log
[2023-08-22T09:26:15.808Z][UP] 🚧🚧🚧🚧🚧 Waiting sync "webcmp-topo-chart-horizontal" task on https://r.cnpmjs.org 🚧🚧🚧🚧🚧
[2023-08-22T09:26:16.190Z][UP] 🚧 HTTP [201] timing: {"queuing":0.05,"connected":0,"requestHeadersSent":0.061,"requestSent":0.096,"waiting":375.73,"contentDownload":381.824}, data: {"ok":true,"logId":"64e47f379792b9ab4541322e"}
[2023-08-22T09:26:23.158Z][UP] 🎉 Sync webcmp-topo-chart-horizontal success [6968ms], log: https://r.cnpmjs.org/webcmp-topo-chart-horizontal/sync/log/64e47f379792b9ab4541322e?offset=0, offset: 263
[2023-08-22T09:26:23.158Z][UP] 🔗 https://r.cnpmjs.org/webcmp-topo-chart-horizontal
[2023-08-22T09:26:26.549Z] HTTP [200] content-length: -, timing: {"queuing":0.079,"connected":0,"requestHeadersSent":0.098,"requestSent":0.149,"waiting":3014.558,"contentDownload":3364.909}
[2023-08-22T09:26:26.549Z] 📖 webcmp-topo-chart-horizontal latest version: 3.2.6, published time: "2023-08-22T09:24:13.223Z"
[2023-08-22T09:26:26.549Z] 🚧 Syncing maintainers: [{"name":"ymrdf","email":"[email protected]"},{"name":"xishu-tech","email":"[email protected]"}]
[2023-08-22T09:26:26.648Z] 🚧 Syncing versions 68 => 69
[2023-08-22T09:26:26.648Z] 🚧 [1] Syncing version 3.2.6, delay: 133425ms [2023-08-22T09:24:13.223Z], tarball: https://r.cnpmjs.org/webcmp-topo-chart-horizontal/-/webcmp-topo-chart-horizontal-3.2.6.tgz
[2023-08-22T09:26:28.922Z] 🚧 [1] HTTP content-length: 2266922, timing: {"queuing":2159.063,"connected":2169.89,"requestHeadersSent":2169.913,"requestSent":2169.944,"waiting":2217.29,"contentDownload":2270.413} => /root/.cnpmcore/downloads/2023/08/22/aa487f88825506958e60-webcmp-topo-chart-horizontal-3.2.6.tgz
[2023-08-22T09:26:29.074Z] 🎉 [1] Synced version 3.2.6 success, packageVersionId: 64e47f4542a9f93ca4e73e7c, db id: 38595320
[2023-08-22T09:26:29.102Z] 🟢 Synced updated 1 versions, removed 0 versions
[2023-08-22T09:26:29.102Z] 🚧 Refreshing manifests to dists ......
[2023-08-22T09:26:29.345Z] 🟢 Refresh use 243ms
[2023-08-22T09:26:29.461Z] 🟢 Synced 1 tags: [{"action":"change","tag":"latest","version":"3.2.6"}]
[2023-08-22T09:26:29.480Z] 📦 Add dependency "@antv/g6" sync task: 64e47f4542a9f93ca4e73e7d, db id: 261524664
[2023-08-22T09:26:29.499Z] 📦 Add dependency "@storybook/addon-postcss" sync task: 64e47f4542a9f93ca4e73e7e, db id: 261524665
[2023-08-22T09:26:29.520Z] 📦 Add dependency "antd" sync task: 64e47f4542a9f93ca4e73e7f, db id: 261524666
[2023-08-22T09:26:29.539Z] 📦 Add dependency "dagre" sync task: 64e47f4542a9f93ca4e73e80, db id: 261524667
[2023-08-22T09:26:29.550Z] 📦 Add dependency "lodash" sync task: 64e47f4542a9f93ca4e73e81, db id: 261524668
[2023-08-22T09:26:29.558Z] 📦 Add dependency "react" sync task: 64e47f4542a9f93ca4e73e82, db id: 261524669
[2023-08-22T09:26:29.568Z] 📦 Add dependency "react-color" sync task: 64e47f4542a9f93ca4e73e83, db id: 261524670
[2023-08-22T09:26:29.578Z] 📦 Add dependency "react-dom" sync task: 64e47f4542a9f93ca4e73e84, db id: 261524671
[2023-08-22T09:26:29.591Z] 📦 Add dependency "react-measure" sync task: 64e47f4542a9f93ca4e73e85, db id: 261524672
[2023-08-22T09:26:29.602Z] 📦 Add dependency "screenfull" sync task: 64e47f4542a9f93ca4e73e86, db id: 261524673
[2023-08-22T09:26:29.610Z] 📦 Add dependency "uuid" sync task: 64e47f4542a9f93ca4e73e87, db id: 261524674
[2023-08-22T09:26:29.623Z] 📦 Add dependency "worker-loader" sync task: 64e47f4542a9f93ca4e73e88, db id: 261524675
[2023-08-22T09:26:29.625Z] 🗑️ Clean cache
[2023-08-22T09:26:29.625Z] 📝 Log URL: https://registry.npmmirror.com/-/package/webcmp-topo-chart-horizontal/syncs/64e47f37f3ded62aa4fff71a/log
[2023-08-22T09:26:29.625Z] 🔗 https://r.cnpmjs.org/webcmp-topo-chart-horizontal?t=1692696383180&cache=0

替换使用纯静态方案实现

问题报告与改动方案

🖼️ 背景

最初,我们计划使用 Next.js 的 Server Side Rendering (SSR)React Server Components (RSC) 来提高我们网站首页的首屏渲染性能。

然而,在实际应用过程中,我们面临了一些挑战。在国内,使用 Vercel 托管的访问速度不尽如人意. 🐌 同时,在使用 阿里云函数计算(Function Compute,FC) 时,我们注意到 Time to First Byte (TTFB) 较高,需要数秒的延时. ⏳ 更进一步,通过 阿里云 Elastic Compute Service (ECS) 进行独立部署,使用 PM2 进行进程托管,但在实际应用过程中,我们多次遇到进程异常退出的问题. 🚧 由于 nextjs 默认没有导出清晰的日志和错误信息,很难进行排查。

改动方案

为了解决这些问题, 我们决定采用 Next.js 提供的 export 模式 并使用 Nginx 进行纯静态托管. 📦 这个改动方案有以下主要特点:

  1. 📌 首页预渲染:我们会对首页进行预渲染, 以确保仍然能够提供出色的访问性能. 🏁

  2. 🛡️ 稳定性:通过纯静态托管和首页预渲染,在生产环境将不再启动 nextjs 提供接口服务,不再担心进程异常退出

  3. 影响:

    a. ❌ 版本列表页校验功能:由于 NPM Registry 接口未提供跨域能力, 因此我们将无法实现版本列表页的自动校验功能.

    b. 🌀 前端拉取完整清单:为了解决部分版本号较多的情况下的性能问题, 前端将需要提前拉取完整的清单. 这可能导致列表页在渲染之前出现轻微的卡顿. 🚦

nginx 配置实例

server {
    listen 80;
    server_name npmmirror.com;

    root /path/to/cnpmweb/out;

    location ^~ /_next/static/ {
        expires 30d;
        try_files $uri $uri/ =404;
    }

    location ^~ /package/ {
        try_files $uri /package/[...slug].html;
    }
    
    location ~ ^/sync/(.*) {
        rewrite ^/sync/(.*) /package/$1 permanent;
    }

    location / {
        try_files $uri $uri/ /index.html;
    }
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.