nats-io / nats.ws

WebSocket NATS
Apache License 2.0
329 stars 29 forks source link

[iOS12] SyntaxError: Unexpected token ';'. Expected an opening '(' before a method's parameter list. #190

Closed toshi1127 closed 1 year ago

toshi1127 commented 1 year ago

I get a runtime error on iOS12. I think it is caused by the generated JavaScript code compiling to use a newer version, is there any way to resolve this?

image

Browser: iOS12
nats.ws version: 1.14.0
aricart commented 1 year ago

possibly some issue with webpack? From the above I cannot tell any point in the library's code.

aricart commented 1 year ago

Can you try to figure out what the code is where that is?

toshi1127 commented 1 year ago

@aricart Thanks for the reply! There is an error in nats.ws/esm/nats.js, but I am unable to figure out the details. Can you please investigate a little bit, as we have created a repository that reproduces the error? If I start the server with yarn run dev and open it in the iOS12 browser, the error occurs.

https://github.com/toshi1127/nats-ws-issues-190

image
aricart commented 1 year ago

@toshi1127 thank you for submitting the test setup - the url for the connect was wrong using something like wss://demo.nats.io:8443 does the right thing.

I don't have the IOs simulator, but on ipad,iphone it works.

aricart commented 1 year ago

PXL_20230315_164310043 PXL_20230315_164629615

aricart commented 1 year ago

Perhaps 12.8 (from 2018) is too old. My guess is that it doesn't support ?: or nullish coalescing ??. You may want to try and shim that for your application. For your information the phone is using a 15.x ios.

aricart commented 1 year ago

For the record, the device was an iPhone 6s Plus from 2015...

toshi1127 commented 1 year ago

@aricart Thanks for the verification ! The iPhone 6s you verified appears to have a newer iOS version than 12. (as the URL of the site is displayed at the bottom of the screen)

I transpiled nats.ws/esm/nats.js in Babel with targets: safari12 and it works.