#window.__TAURI_IPC__ is not a function

34 messages · Page 1 of 1 (latest)

lost kayak
#

Getting the error in the title/screen screenshot when a specific page on my tauri app loads. My css fails to load when I get this error message. According to the console it's coming from this line of my code: const installedDir = await store.get('atavismxi-dir')

I am browsing through other support topics with a similar error message. I am not running tauri in a browser. Not using tauri 2.0.

Possible relevant code surrounding the line giving the error:

  onMount(async () => {
    const store = new Store('.settings.dat')
    const installedDir = await store.get('atavismxi-dir')

    await checkForCli(installedDir + gameFolder + '/Ashita-cli.exe')

    await checkForWine(installedDir)

    cliWatcher = await watch(
      installedDir + gameFolder,
      async (event) => {
        checkForCli(installedDir + gameFolder + '/Ashita-cli.exe')
      },
      { recursive: true },
    )
  })
shrewd coral
#

Can you share the output of tauri info?

lost kayak
#

Yep! It says I'm using solidJS....and I am. But I'm really using astroJS with solidJS added to it.

shrewd coral
#

All those versions look fine.

lost kayak
#

I try to move the store out of the onMount and make the whole component async but then the whole component fails to load

shrewd coral
#

Which framework is interpreting the onMount?

lost kayak
#

That's a solidJS component.
Maybe it's related to astroJS. I'm loading the solidJS component with: client:only='solid-js'

If I load the component with client:load I get errors about window being undefined. I don't know if you're familiar with astroJS. I think I'm goin gto play with client:load and see if I can work through the undefined window errors

shrewd coral
#

It sounds like it's trying to run some code before Tauri could inject it's IPC.

#

You can be confident that this method will run only once after initial rendering is done and won't run on the server.
This sounds like it should never occur before Tauri has a chance to inject the IPC. Have you written any Rust code or is it just the default template?

lost kayak
#

I have written a few commands in main.rs. That's about it.

granite axle
# lost kayak That's a solidJS component. Maybe it's related to astroJS. I'm loading the sol...

If you're involving Astro then it's very important to keep in mind that Astro only does static compilation. So if you use Tauri in literally any Astro code then it's gonna throw error like that, you have to make sure that wherever the IPC is involved in any way shape or form is being ran strictly only when it's actually running in the client

Based on your output that doesn't seem to be the issue, just pointing it out as more of a "fun fact" related to how you gotta think about using Tauri in Astro

#

The dev url looks funky, wonder if that's related

#

I think I just realized what the issue is @lost kayak , your URL leads to Tauri treating your server as if it's a remote url instead of an internal URL, so it doesn't inject any Tauri scripts into it

lost kayak
#

The devPath?

granite axle
#

That's my best guess at least

#

It aligns perfectly with the behavior we're seeing

lost kayak
#

After setting astro to client:loadI removed 75% of the code that was loading and it loads what's left without an error about window not existing. Slowly adding stuff back. I'f this doesn't work out I'll try to change the URL but I can't get cookies without that

granite axle
lost kayak
#
  "build": {
    "beforeBuildCommand": "npm run build",
    "beforeDevCommand": "npm run dev -- --host=localhost.atavismxi.com",
    "devPath": "http://localhost.atavismxi.com:4321",
    "distDir": "../dist"
  },
granite axle
lost kayak
#

oh sorry

#

I don't know if I have one or maybe I'm misunderstanding. Is that in tauri.config.json?

granite axle
lost kayak
granite axle
# lost kayak

Welp that's one of my theories out the window, shoot. Though I do still think it's related to the devPath being treated as remote, tried searching through the Tauri source code a bit to verify my hypothesis but I'm waaaaay too tired to think clearly (it's 4:37 here atm 😅 )

#

So yea my best idea with midnight brain is that you try using a localhost based url and see if that fixes it

lost kayak
#

You must be on the other side of the world. I'm very slowly narrowing down what code causes the errors.

#

I don't know if I have it in me to stay up at midnight my time anymore

granite axle
#

I'm in Sweden so it might be the other side of the world 😅
Anyway imma head to bed now, gotta get a couple hours sleep before it's time to wake up
Hope you find the issue, if not I'll check in sometime tomorrow!

lost kayak
#

it's either watch, exists, or invoke causing it.
I'll have it figured out soon thanks for support means a lot

shrewd coral
#

Tauri's invoke is what calls window.__TAURI_IPC__ so it's probably not that one unless it's crashing early in an uncaught exception.

lost kayak
# shrewd coral Tauri's `invoke` is what calls `window.__TAURI_IPC__` so it's probably not that ...

When I changed astro to use client:load and removed all of import { watch } from 'tauri-plugin-fs-watch-api'it runs fine.
I CAN use watch in a astroJS component. That works fine. When I try watch in a solidJS component it gives me window is not defined. I think I can work with this....it's gong to be weird. The original error, window.__TAURI_IPC__, only happened when I had astro set to client:only='solid-js and I think that might block tauri's javascript? Not sure?