microsoft-authentication-library-for-js
microsoft-authentication-library-for-js copied to clipboard
Creating NativeBrokerPlugin requires process.exit() to shutdown node
Core Library
MSAL Node (@azure/msal-node)
Core Library Version
2.7.0
Wrapper Library
MSAL Node Extensions (@azure/msal-node-extensions)
Wrapper Library Version
1.0.15
Public or Confidential Client?
Public
Description
Node does not shutdown after simply creating a NativeBrokenPlugin
Error Message
None. Node just stays running unless process.exit() is called. I suspect that the NativeBrokerPlugin is listening on a socket and it will continue listening until someone shuts it down. Perhaps offer a way to shutdown the NativeBrokerPlugin when we're done with it. e.g. const plugin = new NativeBrokerPlugin() plugin.dispose()
MSAL Logs
None. Despite trace being turned on
Network Trace (Preferrably Fiddler)
- [ ] Sent
- [ ] Pending
MSAL Configuration
{
auth: {
clientId: 'clientId',
authority: 'https://login.microsoftonline.com/facac3c4-e2a5-4257-af76-205c8a821ddb/'
},
broker: {
nativeBrokerPlugin: new NativeBrokerPlugin()
},
system: {
loggerOptions: {
logLevel: LogLevel.Trace,
loggerCallback: ( level, message, containsPii ): void => {
if ( containsPii ) {
return;
}
switch ( level ) {
case LogLevel.Error:
console.error( message );
return;
case LogLevel.Info:
console.info( message );
return;
case LogLevel.Verbose:
console.debug( message );
return;
case LogLevel.Warning:
console.warn( message );
return;
default:
console.log( message );
return;
}
}
}
}
}
Relevant Code Snippets
import {
LogLevel,
PublicClientApplication
} from '@azure/msal-node';
import { NativeBrokerPlugin } from '@azure/msal-node-extensions';
/******************************************************************************
* Handlers
******************************************************************************/
process.on( 'unhandledRejection', ( reason, promise ) => {
console.log( 'Unhandled Rejection at:', promise, 'reason:', reason );
} );
process.on( 'exit', ()=>console.log( 'Process exit' ) );
/******************************************************************************
* Top Level - First Program Line
******************************************************************************/
main().then( ()=>{
console.log( 'All done in main' );
} ).catch( console.log );
/******************************************************************************
* Function: main
******************************************************************************/
async function main(): Promise<void> {
const cApplication = new PublicClientApplication(
{
auth: {
clientId: 'clientId',
authority: 'https://login.microsoftonline.com/facac3c4-e2a5-4257-af76-205c8a821ddb/'
},
broker: {
nativeBrokerPlugin: new NativeBrokerPlugin()
},
system: {
loggerOptions: {
logLevel: LogLevel.Trace,
loggerCallback: ( level, message, containsPii ): void => {
if ( containsPii ) {
return;
}
switch ( level ) {
case LogLevel.Error:
console.error( message );
return;
case LogLevel.Info:
console.info( message );
return;
case LogLevel.Verbose:
console.debug( message );
return;
case LogLevel.Warning:
console.warn( message );
return;
default:
console.log( message );
return;
}
}
}
}
}
);
//process.exit();
}
Reproduction Steps
Transpile and run the following typescript. Node does not exit properly unless the process.exit() call is uncommented
Expected Behavior
I would not expect to have to call process.exit()
Identity Provider
Entra ID (formerly Azure AD) / MSA
Browsers Affected (Select all that apply)
Other
Regression
No response
Source
External (Customer)
Thanks for flagging this @TheBlueRage. Flagging this for traction internally.
This issue is not stale and still needs attention. Thank you
On Mon, May 13, 2024 at 8:30 AM microsoft-github-policy-service[bot] < @.***> wrote:
@TheBlueRage https://github.com/TheBlueRage This issue has been automatically marked as stale because it is marked as requiring author feedback but has not had any activity for 5 days. If your issue has been resolved please let us know by closing the issue. If your issue has not been resolved please leave a comment to keep this open. It will be closed automatically in 7 days if it remains stale.
— Reply to this email directly, view it on GitHub https://github.com/AzureAD/microsoft-authentication-library-for-js/issues/7076#issuecomment-2107586224, or unsubscribe https://github.com/notifications/unsubscribe-auth/AOPZQFMMYLLWDDLVCMUHD2TZCC6ABAVCNFSM6AAAAABHG46LISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCMBXGU4DMMRSGQ . You are receiving this because you were mentioned.Message ID: <AzureAD/microsoft-authentication-library-for-js/issues/7076/2107586224@ github.com>