-
-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[bug] Unable to call window.__TAURI_INTERNALS__.invoke
from within an initialization_script
#12404
Comments
There's really nothing we can do here I think. The internals are also injected with the initialization script api (there's no way to inject something earlier). |
idk, i think i'll close this in favor of #12348 |
Okay thanks. I wasn't sure if the internals are injected after the user-defined initialization scripts, and it might be possible to just change the order. Or add an |
afaik we cannot influence the order on the webview api level |
I dug into it a bit and it looks like this is caused by the ordering of the Vec I was able to change the ordering so that tauri's built-in initialization scripts come before any user-added initialization scripts in that Vec. Here's my (maybe sloppy) implementation: dev...mattyg:tauri:feat/run-user-initialization-scripts-after-builtin-initialization-scripts -- it resolves the issue shown in my reproduction. I'm happy to tidy it up a bit and open it as a PR. Would you be open to that? I don't think #12348 helps with my issue because I want to inject a script that executes after tauri's built-in scripts, but before any html is parsed. |
I highly doubt this is 100% reliable (on all platforms) but it still makes sense to do, so a pr would be appreciated.
I assumed as much, that doesn't mean you can't use the solution in 12348 though (depending on what the solution will end up being ig) |
Thanks for all your great work!
Describe the bug
When attempting to call
window.__TAURI_INTERNALS__.invoke
from within aninitialization_script
, I get the following error:TypeError: undefined is not an object (evaluating 'window.__TAURI_INTERNALS__.invoke')
Reproduction
Here is a minimal reproduction: https://github.com/mattyg/bug-reproduction-tauri-initialization-script-invoke
(the relevant lines are here: https://github.com/mattyg/bug-reproduction-tauri-initialization-script-invoke/blob/f1bf03103b7ebc57b775f15f54a782ad85135f65/tauri-app/src-tauri/src/lib.rs#L10 )
You can see that calling
window.__TAURI_INTERNALS__.invoke
from within aninitialization_script
succeeds only after a short delay.Expected behavior
I can call
window.__TAURI_INTERNALS__.invoke
from within aninitialization_script
.Full
tauri info
outputStack trace
No response
Additional context
No response
The text was updated successfully, but these errors were encountered: