You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

JS类私有变量赋值后始终为undefined,Edge DevTools显示异常求助

Edge浏览器中JS类私有变量赋值后仍为undefined的已知Bug

问题现象

JS类的私有变量#lastDownload已完成赋值(确认赋值内容非undefined),但代码执行时该变量始终表现为undefined。同时出现以下矛盾现象:

  • DevTools中悬停查看该变量时显示正确值
  • 控制台直接求值该变量结果仍为undefined
  • 仅在Microsoft Edge浏览器中触发此问题,Google Chrome中完全正常

涉及代码

customElements.define("popup-page", class extends HTMLElement {
    // ...
    #lastDownload = 0;
    // ...

    async #download() {
        // ...
        this.#lastDownload = 0;
        // ...

            for (let i = 0; i < urls.length; i++) {
                // ...
                const id = el.downloadId = await this.#attemptItemAsync(url, maxCon, addDelay);
            }
    }

async #attemptItemAsync(url, maxCon, addDelay) {
        try {
            if (addDelay > 0) {
                const now = Date.now();
                if (now - this.#lastDownload < addDelay) {
                    await sleepAsync(now - this.#lastDownload);
                }
                this.#lastDownload = now;
            }
            
            // ...
        }
        catch {
            return;
        }
    }
});

排查结论

  • 代码中不存在任何将#lastDownload赋值为undefined的逻辑
  • 已确认这是Microsoft Edge的已知Bug,且已向官方提交反馈

内容的提问来源于stack exchange,提问作者Luke Vo

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 18:33:15