Skip to content
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

window.__TAURI__.invoke() throws "_this.transformCallback is not a function" #1547

edbrannin opened this issue Apr 20, 2021 · 8 comments


Copy link

edbrannin commented Apr 20, 2021

Describe the bug

Whenever I call window.__TAURI__.invoke(), I get this error:

_this.transformCallback is not a function. (In '_this.transformCallback(function (r) {
        delete window[error];
      }, true)', '_this.transformCallback' is undefined)

To Reproduce


  1. Make a custom command
  2. Run that command with window.__TAURI__.invoke() (see also line 4)

Runnable example:

  1. Clone (at commit: 70a8f04a78ef8e0effc0052ea98077c0be1c2bb8)
  2. Run yarn tauri dev

Expected behavior
A clear and concise description of what you expected to happen.

If applicable, add screenshots to help explain your problem.

Platform and Versions (please complete the following information):

Operating System - Mac OS, version 10.15.7 X64

Node.js environment
  Node.js - 12.20.1
  @tauri-apps/cli - 1.0.0-beta-rc.2
  @tauri-apps/api - 1.0.0

Global packages
  npm - 6.14.11
  yarn - 1.22.10

Rust environment
  rustc - 1.51.0
  cargo - 1.51.0

App directory structure

App - 1.0.0-beta-rc.0
build-type - bundle
CSP - default-src blob: data: filesystem: ws: http: https: 'unsafe-eval' 'unsafe-inline'
distDir - ../build
devPath - http://localhost:3000

Additional context

I've been using window.__TAURI__.invoke() because of #1512 -- I'll try using the imported version now that rc2 is out.

Stack Trace

[Error] Error:
TypeError: _this.transformCallback is not a function. (In '_this.transformCallback(function (r) { resolve(r); delete window[error]; }, true)', '_this.transformCallback' is undefined)
invoke — user-script:3:100
(anonymous function) — App.js:48
(anonymous function) — App.js:30
(anonymous function) — App.js:41
invokePassiveEffectCreate — react-dom.development.js:23487
callCallback — react-dom.development.js:3945
invokeGuardedCallbackDev — react-dom.development.js:3994
invokeGuardedCallback — react-dom.development.js:4056
flushPassiveEffectsImpl — react-dom.development.js:23574
unstable_runWithPriority — scheduler.development.js:468
(anonymous function) — react-dom.development.js:23324
workLoop — scheduler.development.js:417
flushWork — scheduler.development.js:390
performWorkUntilDeadline — scheduler.development.js:157
	(anonymous function) (main.chunk.js:86)
	(anonymous function)
Copy link
Sponsor Member

Can you please update and try again? It seems that is out of date:

Copy link

Whoops, I thought tauri deps update would take care of that. It seems like it's checking, but isn't finding the update...

yarn run v1.22.10
$ tauri deps update
[tauri]: running deps
 dependency:manager Updating dependencies... +0ms
 app:spawn [sync] Running "rustup update" +190ms

info: syncing channel updates for 'stable-x86_64-apple-darwin'

  stable-x86_64-apple-darwin unchanged - rustc 1.51.0 (2fd73fabe 2021-03-23)

info: cleaning up downloads & tmp directories
 dependency:cargo-commands "tauri-bundler" is up to date +942ms
 dependency:crates "tauri" is up to date +298ms
 dependency:npm-packages "@tauri-apps/api" is up to date +2s
 dependency:npm-packages "@tauri-apps/cli" is up to date +1s
✨  Done in 4.99s.

Sorry, I'm a rust newbie; I'll try to figure this out

Copy link
Sponsor Member

dang - you're right! it seems that it won't find the beta. @lucasfernog - got an idea here? this will probably follow us for a while

Copy link

I ran cargo update in src-tauri and it's updated:

    Updating index
    Updating jobserver v0.1.21 -> v0.1.22
    Updating open v1.6.0 -> v1.7.0
    Updating tauri v1.0.0-beta-rc.0 -> v1.0.0-beta-rc.2
    Updating weezl v0.1.4 -> v0.1.5

I tried again and it's still happening.

Copy link

It works when I import invoke, so this may just be a problem with window.__TAURI__:

import { invoke } from '@tauri-apps/api/tauri';

I'm going to move on now, but let me know if I can be useful for resolving the root cause somehow. :)

Copy link
Sponsor Member

Thanks for the headsup and the speedy resolution. Going to close this, since your issue was resolved.

Copy link

Sounds good, though I hope you won't forget to check on window.__TAURI__.invoke() :)

Copy link

Hmmm the issue happened because you changed the context of window.__TAURI__.invoke. I can change it to not rely on this and it'll work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet

No branches or pull requests

3 participants