wails icon indicating copy to clipboard operation
wails copied to clipboard

TypeError: undefined is not an object (evaluating 'window.wails.Events.OnMultiple')

Open ipuppy2 opened this issue 10 months ago • 6 comments

wails 版本信息: wails version : v2.10.1

主要代码如下:

`import { Events } from "@wailsapp/runtime";

Events.On("directoryUpdated", updateImageList);

` 然后就报错了:

Image

Image

ipuppy2 avatar Mar 08 '25 14:03 ipuppy2

I'm having this issue as well. Is there a solution to this?

TypeError: undefined is not an object (evaluating 'window.runtime.EventsOnMultiple')

divmgl avatar Apr 15 '25 10:04 divmgl

I am also getting this issue. Is EventsOnMultiple supposed to be deprecated? My code references EventsOn only.

Image

jherman avatar Apr 22 '25 01:04 jherman

import { Events } from "@wailsapp/runtime"

Where did this come from? The runtime should be in frontend/wailsjs/runtime

leaanthony avatar Apr 23 '25 23:04 leaanthony

When you get this, can you check if window.runtime or window.runtime.EventsOnMultiple is null

leaanthony avatar Apr 23 '25 23:04 leaanthony

Strangely enough I was able to eventually get it to work without throwing this error. I'm not even sure what I did as I did multiple things like

running go clean -cache and go clean -modcache rm -rf node_modules dist wailsjs rebooting

something eventually worked, but I'm not sure. I did grep the directory looking for references and I saw the following:

❯ grep -R 'EventsOnMultiple' frontend/wailsjs
frontend/wailsjs/runtime/runtime.d.ts:// [EventsOnMultiple](https://wails.io/docs/reference/runtime/events#eventsonmultiple)
frontend/wailsjs/runtime/runtime.d.ts:export function EventsOnMultiple(eventName: string, callback: (...data: any) => void, maxCallbacks: number): () => void;
frontend/wailsjs/runtime/runtime.js:export function EventsOnMultiple(eventName, callback, maxCallbacks) {
frontend/wailsjs/runtime/runtime.js:    return window.runtime.EventsOnMultiple(eventName, callback, maxCallbacks);
frontend/wailsjs/runtime/runtime.js:    return EventsOnMultiple(eventName, callback, -1);
frontend/wailsjs/runtime/runtime.js:    return EventsOnMultiple(eventName, callback, 1);

I'm not sure if that helps. If it pops back up, I'll post back.

jherman avatar Apr 24 '25 22:04 jherman

OK I realized I only get this when I use wails dev and I attempt to refresh with the app UI by right clicking and selecting 'refresh'. I see the following:

Image

To answer your question if window.runtime is undefined, it is:

Image

The directory does exist:

Image

My current fix when running from wails dev, is to close the app, and restart wails dev.

jherman avatar Apr 25 '25 18:04 jherman