Open sithembiso opened 1 year ago
I started seeing a similar error on Linux. Same behavior, started out of the blue and was happening consistently, but the error message was:
TypeError: undefined is not an object (evaluating 'window['go']['application']')
This turned out to be an error in my code. I had a link that was supposed to look like this:
<a href="#" data-func="myFunction">
I have a listener dispatching events. When a link with data-func is clicked, the dispatcher finds and calls the function.
The problem was, I had actually written my link like this:
<a href="myFunction">
When I clicked it, I got a blank screen and the error message above. The web view was trying to navigate to a non-existent URL, hence the blank screen and the loss of reference to window['go']. There was no obvious error telling me the webview was trying to load an unloadable resource.
If your error appeared out of the blue and occurs consistently like mine, comb back through your code for recent changes. The problem may not even be in JavaScript. It could be an HTML error, like mine.
I'm not trying to say you haven't found a legitimate bug. I'm just trying to help out. I hope this info is useful to someone.
@sithembiso wails dev
exposes two ports, one on localhost:3000 and the other on localhost:34115. Not sure if this is your issue, but if you choose localhost:3000 you'll get this problem happening.
Any chance that's your issue?
I don't think so. But again, the problem was in my code, not in wails.
I don't think so. But again, the problem was in my code, not in wails.
I've miscommunicated, sorry! My question was aimed at the original reporter. I've updated it to clarify that.
I love your report and fix, though! It's interesting how there's no error coming through for your case.
Similar behavior here.
I have a reproductible case, looks like wails doesn't like refreshing when it's not on /
I have react-router installed and everytime it refreshes when I am not on my main page /
, backend functions are undefined, I need to go back to home /
then everything is fine.
and it matches with the href error of @diamondap
Using a memory router, solves this
I'm seeing the same behavior as @ldlac. The error I get is undefined is not an object (evaluating 'window['go']['main']')
and it goes away if I execute location.replace('/')
. So it appears that something weird happens if the app is refreshed and the path is not /
.
I worked around this by adding if (!('go' in window)) location.replace('/')
to main.jsx
That's a known issue, currently the runtime is only injected for /
or /index.html
. If a SPA framework is used, the runtime is injected for /
if it then internally changes the state to something like /myroute
everything work fine. If now a reload is done with /myroute
the runtime is not injected anymore and results in this error.
Please also see https://github.com/wailsapp/wails/issues/2047 for more information. There are plans to give the developer more freedom to specify where it should be injected, maybe also give them the possibility to trigger the injection with a meta-tag.
I am using Angular template and this error always happens. So I added
<head>
...
...
<!-- Wails runtime: start -->
<script src="/wails/ipc.js"></script>
<script src="/wails/runtime.js"></script>
<!-- Wails runtime: until here -->
</head>
to always inject wails runtime.
I have the same problem. Is there a solution? I use vue+vue-router.
I've also hit this issue. It's quite serious, and effectively makes it impossible to embed MPA projects (such as those built by Astro) with Wails, especially if your app uses redirects. This affects the built production bundle and the dev experience.
I can't comment on how each front-end project hads been built to run but you can just add script tags to your pages to load the necessary code: https://wails.io/docs/guides/frontend/#script-injection
@leaanthony That works for me
I can't comment on how each front-end project hads been built to run but you can just add script tags to your pages to load the necessary code: https://wails.io/docs/guides/frontend/#script-injection
THANKS for pointing that out! I was ready to pull my hair out.
Now it works flawlessly! <3
I have the same problem. Is there a solution? I use vue+vue-router.
我想你可以使用 createWebHashHistory
或者是 createMemoryHistory
模式来解决这个问题。只需修改 frontend\src\router\index.ts
文件即可。
I think you can solve this issue by using the createWebHashHistory
or createMemoryHistory
mode. Simply modify the frontend\src\router\index.ts
file.
我比较推荐使用 createWebHashHistory
模式,因为 createMemoryHistory
模式会导致刷新后回到首页。
I would recommend using the createWebHashHistory
mode, as the createMemoryHistory
mode will cause the page to return to the home page after a refresh.
Description
I am getting this error every time the app hot-reloads. First run is fine, but if I change anything on the frontend, I get a blank screen with this error in the console:
Full output:
The files it's pointing at are auto-generated.
To Reproduce
Honestly, I am not sure as it seemed to just appear out of the blue. For me it happens consistently. Whenever I update the front end, I have to kill
wails dev
and re-run it. Otherwise, I'm stuck with a blank screen.Expected behaviour
I expected it to reload like before without any errors.
Screenshots
Attempted Fixes
No response
System Details