Skip to content

fix: lazy-load @ngrok/ngrok so the CLI works under Windows Smart App Control - #174

Merged
lukaszfiszer-monday merged 1 commit into
masterfrom
fix/analyze-issue
Nov 18, 2026
Merged

lukaszfiszer-monday merged 1 commit into
masterfrom
fix/analyze-issue

Conversation

@lukaszfiszer-monday

Copy link
Copy Markdown
Collaborator

Problem

On Windows 11 with Smart App Control on, mapps code:push, mapps app:deploy and most other commands fail at startup:

An Application Control policy has blocked this file ... ngrok.win32-x64-msvc.node
Code: ERR_DLOPEN_FAILED

services/tunnel-service.ts imported @ngrok/ngrok at the top level, and apps-service imports getTunnelingDomain (a plain HTTP call) from it. Through utils/region and dynamic-choices-service, about 27 commands loaded the unsigned ngrok native addon, not only tunnel:create. No signed ngrok build exists, so upgrading doesn't help.

Fix

  • @ngrok/ngrok is now loaded with a dynamic import() inside createTunnelConnection, so only tunnel:create needs it.
  • If the OS blocks the addon (ERR_DLOPEN_FAILED / "Application Control policy"), tunnel:create explains this and suggests WSL2/Docker. Any other load failure gives "Failed to load the ngrok module required for tunneling." Both keep the original error message and cause, and the load happens outside the try, so the generic "Failed to create tunnel connection." can't replace it.
  • types/commands/tunnel.ts now uses import type.
  • A new @typescript-eslint/no-restricted-imports rule rejects value imports of @ngrok/ngrok (type imports are allowed).
  • Version bumped to 4.11.2.

tunnel:create itself still can't run under Smart App Control, because the binary is unsigned. The new error message points to the WSL2/Docker workaround.

Testing

  • New tunnel-service.test.ts: happy path, blocked by OS policy, and generic load failure. The failure tests fail if the load error gets replaced by the generic error.
  • yarn lint (0 errors), yarn test, yarn build. The compiled dist/services/tunnel-service.js only has the dynamic import('@ngrok/ngrok').
  • Manual check on macOS, with the ngrok .node files replaced by junk to reproduce ERR_DLOPEN_FAILED:
    • mapps app:list works.
    • mapps tunnel:create shows the new error with the original dlopen error underneath.
    • With the files restored, mapps tunnel:create connects normally.
  • Not tested on real Windows with Smart App Control.

Links

🤖 Generated with Claude Code

…Control

tunnel-service imported @ngrok/ngrok at the top level, and apps-service
imported getTunnelingDomain from it. Through utils/region and
dynamic-choices-service, ~27 commands (code:push, app:deploy, code:logs,
app:list, scheduler:*, storage:*, ...) loaded the unsigned ngrok native addon
at startup. Windows Smart App Control blocks that addon, so those commands
failed with ERR_DLOPEN_FAILED.

- Load @ngrok/ngrok with a dynamic import inside createTunnelConnection, so
  only tunnel:create needs it
- Report a clear error when the OS blocks the addon (suggest WSL2/Docker),
  or a generic load error otherwise; both keep the original error as cause
- Make the type import in types/commands/tunnel type-only
- Add a lint rule rejecting value imports of @ngrok/ngrok
- Bump version to 4.11.2

DoW: https://monday.monday.com/boards/8441268359/pulses/13503936493
Task: https://monday.monday.com/boards/18426314812/pulses/13570920106

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@lukaszfiszer-monday
lukaszfiszer-monday merged commit cf7819a into master Nov 18, 2026
4 checks passed
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

Successfully merging this pull request may close these issues.

3 participants