walletconnect-monorepo: Error: Missing or invalid topic field

We are seeing a lot of errors coming from the wallet connect socket transport all the below: Error: Missing or invalid topic field

Logs:

message: "Uncaught (in promise): Error: Missing or invalid topic field↵Error: Missing or invalid topic field↵    at SocketTransport.send (https://localhost:4251/default~modules-approval-approval-module~modules-change-password-change-password-module~modules-chan~60cd62e9.js:1560:19)↵    at WalletConnect.<anonymous> (https://localhost:4251/default~modules-approval-approval-module~modules-change-password-change-password-module~modules-chan~60cd62e9.js:698:29)↵    at Generator.next (<anonymous>)↵    at fulfilled (https://localhost:4251/vendor.js:212225:58)↵    at ZoneDelegate.invoke (https://localhost:4251/polyfills.js:440:30)↵    at Object.onInvoke (https://localhost:4251/vendor.js:56946:33)↵    at ZoneDelegate.invoke (https://localhost:4251/polyfills.js:439:36)↵    at Zone.run (https://localhost:4251/polyfills.js:197:47)↵    at https://localhost:4251/polyfills.js:938:38↵    at ZoneDelegate.invokeTask (https://localhost:4251/polyfills.js:475:35)"
stackTrace: "send (webpack:///node_modules/@walletconnect/socket-transport/dist/cjs/index.js:57:)↵tslib_1.__awaiter (webpack:///node_modules/@walletconnect/core/dist/cjs/index.js:577:)↵fulfilled (webpack:///node_modules/tslib/tslib.es6.js:70:41)↵invoke (webpack:///node_modules/zone.js/dist/zone.js:396:)↵onInvoke (webpack:///node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:27815:)↵invoke (webpack:///node_modules/zone.js/dist/zone.js:395:)↵run (webpack:///node_modules/zone.js/dist/zone.js:153:)↵zone.scheduleMicroTask (webpack:///node_modules/zone.js/dist/zone.js:894:)↵invokeTask (webpack:///node_modules/zone.js/dist/zone.js:431:)↵scheduleResolveOrReject (webpack:///node_modules/zone.js/dist/zone.js:836:)↵function (webpack:///node_modules/zone.js/dist/zone.js:750:)↵rejected (webpack:///node_modules/tslib/tslib.es6.js:71:87)↵invoke (webpack:///node_modules/zone.js/dist/zone.js:396:)↵onInvoke (webpack:///node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:27815:)↵invoke (webpack:///node_modules/zone.js/dist/zone.js:395:)↵run (webpack:///node_modules/zone.js/dist/zone.js:153:)↵zone.scheduleMicroTask (webpack:///node_modules/zone.js/dist/zone.js:894:)↵invokeTask (webpack:///node_modules/zone.js/dist/zone.js:431:)↵onInvokeTask (webpack:///node_modules/@angular/core/__ivy_ngcc__/fesm5/core.js:27803:)"

Our setup looks fine so not sure why it keeps erroring. It actually keeps working and does not break but would rather not have that error emitting in the console.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Reactions: 22
  • Comments: 36 (4 by maintainers)

Commits related to this issue

Most upvoted comments

I’m getting the same error probably for the exact reason pedrouid indicated: I’m calling disconnect before sending anything. The reason I’m doing so it because I want to discard the old (cached) connection and scan a new QR code.

Maybe there is a more elegant way ensure that “startSession” actually starts a brand new connection and does not just reuse an old cashed connection?

PS: here is the workaround for my use case. If you want to make sure that walletconnect starts in a clean state, just delete its local storage before initializing it: window.localStorage.removeItem(‘walletconnect’);

This issue was opened almost 2 years ago. C’mon dev team

same, I am still getting this issue

Same problem here when connecting to metamask via walletconnect on mobile

I encountered this issue, and was able to get past it. It seems like this happens when the params are not available. I checked my code, and there were some bugs which were not setting the required params correctly. Once I ensured everything was correct in code, this error was gone.

Possible Unhandled Promise Rejection (id: 2):
Error: Missing or invalid topic field
Error: Missing or invalid topic field
    at send (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:245697:26)
    at _sendResponse$ (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:237871:37)
    at call (native)
    at tryCatch (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:28362:23)
    at invoke (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:28532:32)
    at anonymous (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:28404:30)
    at call (native)
    at tryCatch (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:28362:23)
    at invoke (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:28434:30)
    at anonymous (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:28444:21)
    at tryCallOne (/Users/distiller/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:53:16)
    at anonymous (/Users/distiller/hermes/build_iphoneos/lib/InternalBytecode/InternalBytecode.js:139:27)
    at apply (native)
    at anonymous (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:33854:26)
    at _callTimer (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:33750:17)
    at _callReactNativeMicrotasksPass (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:33789:17)
    at callReactNativeMicrotasks (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:33998:44)
    at __callReactNativeMicrotasks (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:27201:46)
    at anonymous (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:26980:45)
    at __guard (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:27184:15)
    at flushedQueue (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:26979:21)
    at callFunctionReturnFlushedQueue (http://172.20.10.6:8081/index.bundle?platform=ios&dev=true&minify=false&modulesOnly=false&runModule=true&app=com.wallet:26961:33)

Facing this error when trying to approveSession. This is happening 1/5 times on an average.

@luziusmeisser 's window.localStorage.removeItem('walletconnect'); solution works except I sometimes get 2 QR codes when provider.enable() is triggered after window.localStorage.removeItem('walletconnect'); . Anybody knows the solution to this ?.

Same problem 😕 But my app work anyway