Firefox工人中的ECMAScript模块,但有时只能起作用吗? (comlink)

发布于 2025-02-01 16:37:56 字数 1227 浏览 3 评论 0原文

我有点困惑,我想我只是让自己更困惑。

firefox显然不支持 ecmascript模块,但是我正在开始工作。表现不一致。我有一个使用ComLink和ES6模块的项目。当我用Firefox运行它时,它似乎可以正常工作。

...直到昨天,我们在Firefox 100上有一个客户,他正在获取DatacLoneError:无法克隆该对象。。我在众多设备上安装了许多版本的Firefox,但我似乎无法重新创建问题。我让客户重置他们的浏览器,但没有运气修复它。

我的comlink工人就是这样:

import { FetchFromId } from "./deobf";

export const Fetch = async (id: string): Promise<CustomObject | Error> => {
    return FetchFromId(id);
};

称为这样:(

import { FetchFromId } from "./deobf";

if (window.Worker) {
  WORKER = new ComlinkWorker<typeof import('./worker')>(new URL('./worker', import.meta.url), { type: "module" });
}
const res = await (WORKER ? WORKER.Fetch(id) : FetchFromId(id)); // DataCloneError: The object could not be cloned

comlinkworker来自在这里

当我在Firefox 100中运行此操作时,是否应该因为不支持它而丢下错误?

I'm a bit confused, and I think I'm just confusing myself more.

Firefox apparently does not support ECMAScript modules inside Workers, however I'm getting inconsistent performance with it. I have a project that uses Comlink and ES6 modules. When I ran it in Firefox, it seemed to work fine.

... Until yesterday, we had a client on Firefox 100 who's getting DataCloneError: The object could not be cloned.. I've installed numerous versions of Firefox on numerous devices, and I can't seem to recreate the issue. I had the client reset their browser, but no luck fixing it.

My Comlink worker is something like this:

import { FetchFromId } from "./deobf";

export const Fetch = async (id: string): Promise<CustomObject | Error> => {
    return FetchFromId(id);
};

And it's called like this:

import { FetchFromId } from "./deobf";

if (window.Worker) {
  WORKER = new ComlinkWorker<typeof import('./worker')>(new URL('./worker', import.meta.url), { type: "module" });
}
const res = await (WORKER ? WORKER.Fetch(id) : FetchFromId(id)); // DataCloneError: The object could not be cloned

(ComlinkWorker is from here)

When I run this in Firefox 100, should it not throw an error because it's not supported?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文