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

Uncaught TypeError: interop.NSErrorWrapper is not a function #1

Closed
kmahelona opened this issue Oct 7, 2023 · 20 comments
Closed

Uncaught TypeError: interop.NSErrorWrapper is not a function #1

kmahelona opened this issue Oct 7, 2023 · 20 comments

Comments

@kmahelona
Copy link

Summary

When calling .initFromUrl in iOS, if the file at the URL is invalid (e.g. an empty file), the player throws an error,

// player.js:153
if (errorRef && errorRef.value) {
  throw interop.NSErrorWrapper(errorRef.value);
}

I'm unable to catch this error and prevent the app from crashing.

***** Fatal JavaScript exception - application has been terminated. *****
  NativeScript encountered a fatal error: Uncaught TypeError: interop.NSErrorWrapper is not a function
  at
  (file: src/webpack:/nativescript-app/node_modules/@nativescript-community/audio/ios/player.js:153:0)
@felixkrautschuk
Copy link

@farfromrefug is there any update on this? I also notice the exact same thing on iOS with latest NativeScript 8.8 and latest plugin version 6.4.8.

@farfromrefug
Copy link
Member

@felixkrautschuk ok i see the error will fix right away. Sorry for the delay

@farfromrefug
Copy link
Member

@felixkrautschuk @kmahelona just published 6.4.9 could you try? Sorry for the long long long delay...

@felixkrautschuk
Copy link

felixkrautschuk commented Oct 23, 2024

@farfromrefug thanks for your quick response!

Unfortunately, 6.4.9 has a similar error:
Uncaught TypeError: interop.NSErrorWrapper is not a constructor.

I tried to check what interop.NSErrorWrapper is and when loggin it to the console, I get undefined.

@felixkrautschuk
Copy link

Ah, I see you alredy noticed that some time ago, NSErrorWrapper is missing in v8 ios runtime

NativeScript/ios#239

@farfromrefug
Copy link
Member

@felixkrautschuk indeed i forgot about it and was looking at the typings before and it is still there ...
ok will remove it

@farfromrefug
Copy link
Member

@felixkrautschuk new version available

@felixkrautschuk
Copy link

@farfromrefug thanks for the new version.

Unfortunately, the app is still crashing with the native error.
This is what I am doing:

player.initFromUrl(options).then(() => {
    //...
}, (e) => {
    console.log("player initialization failed:");
    console.log(e);
    ///show some error dialog
});

So the Promise from initFromUrl method is being rejected as expected, so I see error message in the console.
But then I would expect the app not to crash. At least, that's the way it works on Android side.

I tried to wrap the whole thing in a try-catch, but it does not help (probably because the whole initUrl is asynchronous).

@farfromrefug
Copy link
Member

@kmahelona what s the crash log now? it cant be the same and i need it

@felixkrautschuk
Copy link

In my case, I have no internet connection so I want the app to show an error dialog.

But in addition, the app crashes and that is not the expected behavior

The error is the following:

Error: Es besteht anscheinend keine Verbindung zum Internet.
***** Fatal JavaScript exception - application has been terminated. *****
NativeScript encountered a fatal error:
Uncaught Error: Der Vorgang konnte nicht abgeschlossen werden. (OSStatus-Fehler -10875.)
at
wrapError(file: node_modules/@nativescript-community/audio/utils.ios.js:1:7)
at wrapNativeException(file: node_modules/@nativescript-community/audio/utils.ios.js:9:0)
at (file: node_modules/@nativescript-community/audio/player.ios.js:157:49)

Error Domain=NSURLErrorDomain Code=-1009 "Es besteht anscheinend keine Verbindung zum Internet." UserInfo={_kCFStreamErrorCodeKey=50, NSUnderlyingError=0x6000031d6be0 {Error Domain=kCFErrorDomainCFNetwork Code=-1009 "(null)" UserInfo={_kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=50, _NSURLErrorNWResolutionReportKey=Resolved 0 endpoints in 4ms using unknown from cache, _NSURLErrorNWPathKey=unsatisfied (No network route)}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask <80A346BB-2C31-4574-8E15-835DBCA9C182>.<16>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask <80A346BB-2C31-4574-8E15-835DBCA9C182>.<16>"
), NSLocalizedDescription=Es besteht anscheinend keine Verbindung zum Internet., NSErrorFailingURLStringKey=..., NSErrorFailingURLKey=..., _kCFStreamErrorDomainKey=1}

@farfromrefug
Copy link
Member

@felixkrautschuk did you catch that error? cause the error is totally normal here

@felixkrautschuk
Copy link

Yes the error itself ist correct but the app crashes. I try to wrap everything into a try catch block but the app is still crashing

@farfromrefug
Copy link
Member

@felixkrautschuk are you sure it is not crashing later on?

@felixkrautschuk
Copy link

Yes I am sure. If I comment that throw statement in the plugin code, only the Promise of the initFromUrl method is being rejected and the app continues to run, which is what I would expect.
But with that throw-statement, I am not able to catch this exception because the initFromUrl Method is asynchronous.

@farfromrefug
Copy link
Member

Yes I am sure. If I comment that throw statement in the plugin code, only the Promise of the initFromUrl method is being rejected and the app continues to run, which is what I would expect. But with that throw-statement, I am not able to catch this exception because the initFromUrl Method is asynchronous.

Yes you are with async and try/catch await

@felixkrautschuk
Copy link

Unfortunately, this doen't help. The app is still crashing.

try {
    await player.initFromUrl(options);
} catch (e) {
    console.log("exception!");
}

I see the message in the console but in addition, the app crashes

Uncaught Error: The operation couldn’t be completed. (OSStatus error 1954115647.)
at
wrapError(file: app/webpack:/ns-audio/node_modules/@nativescript-community/audio/utils.ios.js:1:7)
at wrapNativeException(file: app/webpack:/ns-audio/node_modules/@nativescript-community/audio/utils.ios.js:9:0)
at (file: app/webpack:/ns-audio/node_modules/@nativescript-community/audio/player.ios.js:157:49)

@felixkrautschuk
Copy link

I created a new NS app as a sample project:

ns-audio.zip

@farfromrefug
Copy link
Member

@felixkrautschuk Ok i ll look At it but won't be before november

@farfromrefug
Copy link
Member

@felixkrautschuk new version published with the fix!

@felixkrautschuk
Copy link

@farfromrefug sorry for late reply. Not it is working as expected, thank you for the fix!

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

No branches or pull requests

3 participants