GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — Potential missing iOS polyfill (`node:module` polyfill is missing `createRequire` which Android seem to have) · Issue #11549 · NativeScript/NativeScript Open DescriptionIssue DescriptionI've tried an experiment which seems to be working fine. However I faced an issue on iOS and I'm not sure if it's a runtime issue or not. Scenario: To integrate SignalR library in the past I had used different libraries but never the official microsoft library. I wanted to be sure that reconnecting the socket and refresh token works well, so I thought let me try microsoft's JS client directly. I went ahead and used mircosoft's JS client. Sample code (didn't put all the code here): import { HubConnectionBuilder, HttpTransportType, HubConnectionState, LogLevel } from '@microsoft/signalr'; require('@valor/nativescript-websockets'); let connection; const getAccessToken = () => { const { token, onRefreshToken } = socketConfig || {}; if (typeof onRefreshToken === 'function') { return onRefreshToken() || token; } return token; }; const build = () => { const { url, handlers } = socketConfig; connection = new HubConnectionBuilder() .withUrl(url, { accessTokenFactory: () => getAccessToken(), skipNegotiation: true, transport: HttpTransportType.WebSockets }) .withAutomaticReconnect([0, 2000, 5000, 10000, 30000]) .configureLogging(LogLevel.Warning) .build(); }; export const initSignalRSocket = async config => { if (connection) { return connection; } socketConfig = config; build(); return start(); }; On Android I had no issues whatsoever. Connection worked, events worked, reconnection worked too. Then I went ahead to test out iOS and I got this error: The error seems to be triggered from here: https://github.com/dotnet/aspnetcore/blob/main/src/SignalR/clients/ts/signalr/src/FetchHttpClient.ts#L28 (there's a few other places that have this type of require logic). I managed to get it to work by patching the SignalR library. But my thinking was, if this worked on Android, why shouldn't it work on iOS? When investigating via claude, it pointed out that there might be a missing polyfill when requiring node modules. From my end:
I'm attaching claude's overview of the issue: ns-issue-node-module.md I'm also sending over the SignalR library patch I added to have iOS work: @microsoft+signalr+10.0.11.patch ReproductionNo response Relevant log output (if applicable)Native stack trace: 1 0x1068081e8 tns::LogError(v8::Isolate*, v8::TryCatch&) + 60 2 0x106825480 tns::ModuleInternal::LoadESModule(v8::Isolate*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 3860 3 0x106828658 tns::ModuleInternal::LoadScript(v8::Isolate*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>> const&) + 64 4 0x10679ad44 tns::ResolveModuleCallback(v8::Local<v8::Context>, v8::Local<v8::String>, v8::Local<v8::FixedArray>, v8::Local<v8::Module>) + 18528 5 0x10679fdfc tns::ImportModuleDynamicallyCallback(v8::Local<v8::Context>, v8::Local<v8::ScriptOrModule>, v8::Local<v8::String>, v8::Local<v8::FixedArray>) + 6220 6 0x106bb920c v8::internal::Isolate::RunHostImportModuleDynamicallyCallback(v8::internal::Handle<v8::internal::Script>, v8::internal::Handle<v8::internal::Object>, v8::internal::MaybeHandle<v8::internal::Object>) + 776 7 0x106db427c v8::internal::Runtime_DynamicImportCall(int, unsigned long*, v8::internal::Isolate*) + 276 Environment
Please accept these terms
Activity
|
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |