New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
An exception when trying it out the package in a chrome extension (service-worker.js file) #83
Comments
@medamine980 hi, please provide more info to debug the problem.
|
|
@medamine980 did you tried another translators? If no, try this and add comments about status, is still the same error occurs for you or not. You can try YandexTranslator and LibreTranslateTranslator, also you can try GoogleTranslatorTokenFree. Please, show a full error stack trace and give the source code of extension you work on |
Okey I tried to use it on a new clean extension to make sure if the error is coming from the package, and in fact it is.
|
@medamine980 as i know, manifest version v3 run code in service worker instead of background script. It looks the problem are here. Translate tools did not tested for web workers and probably some API are not available in service worker environment. It looks you found a bug, translate tools must works well for every browser environment. Thanks for your report. It will fixed when we will detect whats code not available in service worker. We have to investigate the stack traces to detect the problem. If you can do, i would appreciate your help. Otherwise i will investigate this bug myself when will have a time. |
So it seems, there is some variable
|
@medamine980 it is good findings. You are right, translators uses I will investigate how to solve this problem better and probably will replace fetcher to a https://github.com/sindresorhus/ky For now i working on refactoring this package, i think fix will be available on next week. This bug shows me that we need a testing in real browser with tools like playwright/puppeteer, to ensure we cover all users scenarios |
Alright, looking forward to the fix! ky seems easier than fetch. Can you help me understand how playwright/puppeteer would help you to test all scenarios? as far as I know those are tools used for web scraping, and I'm not sure other scenarios exist, I mean we have a normal script or a web worker script, and since it is compiled down (by webpack or other bundlers) to an old version of js, means most browser versions would work fine.
|
Off course. We have to add tests for translators in a WebWorker context. WebWorker does not exists in nodejs as i know, so we can't implement test case properly. Thus we need an actual WebWorker environment. We can run tests in headless chrome with tools like playwright/puppeteer. If you have idea how to test code in WebWorker context, with no run headless browser, i would be glad to know. |
Well, there is something called Worker Threads in nodejs... Otherwise you could somehow write the code you want to test in a script, and then write a nodejs script that will open the browser and execute your code in a webworker... |
Hey,
so I just tried out the code presented in the README.md file, and this error popped up
Uncaught (in promise) TypeError: (t.adapter || s.adapter) is not a function
I'd like to note that I am using webpack to bundle this file and also it works fine in the popup.
The text was updated successfully, but these errors were encountered: