⚡ Sangsakala Proxy 🏠 Home
Skip to content

Potential missing iOS polyfill (node:module polyfill is missing createRequire which Android seem to have) #11549

Open

Description

@dangrima90

Issue Description

I'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:

  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

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 don't know if the approach I'm using makes sense. But my thinking is that the SignalR client works on node so possibly it could work on mobile in this case. Which I successfully tested on Android.
  • I don't know if the issue being highlighted by claude actually makes sense.

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

Reproduction

No 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

@nativescript/core: 9.0.20
@nativescript/android: 9.0.4
@nativescript/ios: 9.0.3
@nativescript/webpack: 5.0.36
@microsoft/signalr: 10.0.11

Please accept these terms

Activity

  1. changed the title [-]Potential missing iOS polyfill[/-] [+]Potential missing iOS polyfill (`node:module` polyfill is missing `createRequire` which Android seem to have)[/+] on Oct 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions