Conversation
User Test ResultsTest specification and instructions
Results TemplateTest Artifacts |
a3b9712 to
5ba298c
Compare
The existing ngrok package is no longer maintained, so this commit switches to @ngrok/ngrok. However, this means a number of deployment changes, as the new module uses a node binary module rather than a standalone executable, and the path to the module is assumed to be on the Node search path. The new module also requires VC++ redistributable, so installation of that has been added to the Server Options dialog. Use of ngrok with Keyman Developer Server should be in theory possible with non-Windows platforms with this change, if the user installs the appropriate @ngrok binary package (e.g. @ngrok/ngrok-darwin-universal) globally before starting the server. Fixes: #15625 Build-bot: skip release:developer
5ba298c to
7d8e397
Compare
| # See https://github.com/bubenshchykov/ngrok/issues/254, https://github.com/bubenshchykov/ngrok/pull/255 | ||
| # TODO: this is horrible; is there a way we can avoid this? | ||
| rm -f "$KEYMAN_ROOT"/node_modules/ngrok/bin/ngrok | ||
| rm -f "$KEYMAN_ROOT"/node_modules/ngrok/bin/ngrok.exe |
There was a problem hiding this comment.
This is no longer required with the new ngrok module
The existing ngrok package is no longer maintained, so this commit switches to @ngrok/ngrok. However, this means a number of deployment changes, as the new module uses a node binary module rather than a standalone executable, and the path to the module is assumed to be on the Node search path. The new module also requires VC++ redistributable, so installation of that has been added to the Server Options dialog. Use of ngrok with Keyman Developer Server should be in theory possible with non-Windows platforms with this change, if the user installs the appropriate @ngrok binary package (e.g. @ngrok/ngrok-darwin-universal) globally before starting the server. Fixes: #15625 Build-bot: skip release:developer Cherry-pick-of: #15626 Test-bot: skip
ermshiperete
left a comment
There was a problem hiding this comment.
ngrokBinPath and ngrokControlPort in config.ts seem to be unused now.
|
|
||
| function TfrmServerOptions.RedistInstallerPath: string; | ||
| begin | ||
| Result := TServerDebugAPI.ServerBinPath + SVCRedistExeFilename; |
There was a problem hiding this comment.
Do we need a path separator?
| let started = false; | ||
| const listener = await ngrok.forward({ | ||
| proto: 'http', | ||
| addr: configuration.port, | ||
| authtoken: configuration.ngrokToken, | ||
| onLogEvent: (msg: string) => { | ||
| if(options.ngrokLog) { | ||
| console.log(chalk.cyan(('\n'+msg).split('\n').join('\n[ngrok] ').trim())); | ||
| } | ||
| }, | ||
| onStatusChange: (state: string) => { | ||
| if(state == 'connected' && started) { | ||
| // We only announce reconnection after initial start | ||
| configuration.ngrokEndpoint = listener.url(); | ||
| console.log(chalk.blueBright('ngrok tunnel reconnected at %s'), configuration.ngrokEndpoint); | ||
| } else if(state == 'closed') { | ||
| configuration.ngrokEndpoint = ''; | ||
| console.log(chalk.blueBright('ngrok tunnel closed')); | ||
| } | ||
| } | ||
| }); |
There was a problem hiding this comment.
Identified by devin.ai:
Unhandled exception in startNGrok crashes the entire server
If ngrok.forward() throws an exception (e.g., invalid auth token, network error, binary load failure), the error propagates through startNGrok → run() → top-level, crashing the entire Keyman Developer Server process.
Root Cause
In the new code at developer/src/server/src/index.ts:128-148, the ngrok.forward() call is not wrapped in a try-catch:
const listener = await ngrok.forward({
proto: 'http',
addr: configuration.port,
...
});This is called via await startNGrok() at line 101 inside run(), which itself is awaited at line 30. The top-level catch at line 31-34 captures to Sentry and re-throws, terminating the process.
In the old code, ngrok was started inside an un-awaited IIFE (async function() { ... })(), meaning ngrok errors were fire-and-forget and would not crash the server. The server would continue running without ngrok.
With the new code, any ngrok startup failure (wrong auth token, missing binary, network issues) kills the entire server, preventing all keyboard testing functionality even for local use.
Impact: Users with misconfigured ngrok settings (e.g., invalid token, missing dependencies) will be unable to start Keyman Developer Server at all, even though ngrok is an optional feature.
|
|
||
| let started = false; | ||
| const listener = await ngrok.forward({ | ||
| proto: 'http', |
There was a problem hiding this comment.
From devin.ai:
proto field passed to ngrok.forward() is documented as ignored/unused
At developer/src/server/src/index.ts:129, the proto: 'http' option is passed to ngrok.forward(). Looking at the @ngrok/ngrok v1.7.0 type definitions, proto is listed as an optional string property in the Config interface but the new @ngrok/ngrok SDK defaults to HTTPS scheme. The old ngrok package used proto: 'http' to mean 'create an HTTP tunnel'. In the new SDK, the equivalent would be scheme: 'HTTP' if you want HTTP specifically. With proto: 'http', the SDK may still default to HTTPS, which should still work correctly (it creates an HTTPS public URL forwarding to local HTTP). Not a bug, but the proto field may not be doing what the developer expects.
| } | ||
| }); | ||
| started = true; | ||
| configuration.ngrokEndpoint = listener.url(); |
There was a problem hiding this comment.
| configuration.ngrokEndpoint = listener.url(); | |
| configuration.ngrokEndpoint = listener.url() ?? ''; |
darcywong00
left a comment
There was a problem hiding this comment.
Just a few maintenance questions
| // Note, we manually update the version of ngrok as required in subsequent | ||
| // releases, rather than trying to handle a potentially moving target | ||
| SNgrokVersion = 'v1.7.0'; |
There was a problem hiding this comment.
This should match package.json, right?
Should we add ngrok as an external component in minimum-versions.inc.sh?
| // releases, rather than trying to handle a potentially moving target | ||
| SNgrokVersion = 'v1.7.0'; | ||
| SUrlNgrokDownload = 'https://github.com/ngrok/ngrok-javascript/releases/download/'+SNgrokVersion+'/ngrok.win32-ia32-msvc.node'; | ||
| SNgrokNodeModuleFilename = 'ngrok-win32-ia32-msvc.node'; |
There was a problem hiding this comment.
Is there a filename limitation where we couldn't use ngrok.win32-ia32-msvc.node and then include that in the SUrlNgrokDownload path?
The existing ngrok package is no longer maintained, so this PR switches to @ngrok/ngrok. However, this means a number of deployment changes, as the new module uses a node binary module rather than a standalone executable, and the path to the module is assumed to be on the Node search path.
The new module also requires VC++ redistributable, so installation of that has been added to the Server Options dialog.
Use of ngrok with Keyman Developer Server should be in theory possible with non-Windows platforms with this change, if the user installs the appropriate @ngrok binary package (e.g. @ngrok/ngrok-darwin-universal) globally before starting the server.
Fixes: #15625
Build-bot: skip release:developer
User Testing