push neon reactor

This commit is contained in:
2026-07-12 15:11:38 +02:00
parent 172e72dbcd
commit aeab5f7820
9597 changed files with 2407488 additions and 0 deletions
@@ -0,0 +1,24 @@
import { CrossPlatformLockOptions } from "./CrossPlatformLockOptions.js";
import { Logger } from "@azure/msal-common/node";
/**
* Cross-process lock that works on all platforms.
*/
export declare class CrossPlatformLock {
private readonly lockFilePath;
private lockFileHandle;
private readonly retryNumber;
private readonly retryDelay;
private logger;
constructor(lockFilePath: string, logger: Logger, lockOptions?: CrossPlatformLockOptions);
/**
* Locks cache from read or writes by creating file with same path and name as
* cache file but with .lockfile extension. If another process has already created
* the lockfile, will back off and retry based on configuration settings set by CrossPlatformLockOptions
*/
lock(): Promise<void>;
/**
* unlocks cache file by deleting .lockfile.
*/
unlock(): Promise<void>;
private sleep;
}
@@ -0,0 +1,95 @@
/*! @azure/msal-node-extensions v1.5.17 2025-07-08 */
'use strict';
import { promises } from 'fs';
import { pid } from 'process';
import { Constants } from '../utils/Constants.mjs';
import { PersistenceError } from '../error/PersistenceError.mjs';
import { isNodeError } from '../utils/TypeGuards.mjs';
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
/**
* Cross-process lock that works on all platforms.
*/
class CrossPlatformLock {
constructor(lockFilePath, logger, lockOptions) {
this.lockFilePath = lockFilePath;
this.retryNumber = lockOptions ? lockOptions.retryNumber : 500;
this.retryDelay = lockOptions ? lockOptions.retryDelay : 100;
this.logger = logger;
}
/**
* Locks cache from read or writes by creating file with same path and name as
* cache file but with .lockfile extension. If another process has already created
* the lockfile, will back off and retry based on configuration settings set by CrossPlatformLockOptions
*/
async lock() {
for (let tryCount = 0; tryCount < this.retryNumber; tryCount++) {
try {
this.logger.info(`Pid ${pid} trying to acquire lock`);
this.lockFileHandle = await promises.open(this.lockFilePath, "wx+");
this.logger.info(`Pid ${pid} acquired lock`);
await this.lockFileHandle.write(pid.toString());
return;
}
catch (err) {
if (isNodeError(err)) {
if (err.code === Constants.EEXIST_ERROR ||
err.code === Constants.EPERM_ERROR) {
this.logger.info(err.message);
await this.sleep(this.retryDelay);
}
else {
this.logger.error(`${pid} was not able to acquire lock. Ran into error: ${err.message}`);
throw PersistenceError.createCrossPlatformLockError(err.message);
}
}
else {
throw err;
}
}
}
this.logger.error(`${pid} was not able to acquire lock. Exceeded amount of retries set in the options`);
throw PersistenceError.createCrossPlatformLockError("Not able to acquire lock. Exceeded amount of retries set in options");
}
/**
* unlocks cache file by deleting .lockfile.
*/
async unlock() {
try {
if (this.lockFileHandle) {
// if we have a file handle to the .lockfile, delete lock file
await promises.unlink(this.lockFilePath);
await this.lockFileHandle.close();
this.logger.info("lockfile deleted");
}
else {
this.logger.warning("lockfile handle does not exist, so lockfile could not be deleted");
}
}
catch (err) {
if (isNodeError(err)) {
if (err.code === Constants.ENOENT_ERROR) {
this.logger.info("Tried to unlock but lockfile does not exist");
}
else {
this.logger.error(`${pid} was not able to release lock. Ran into error: ${err.message}`);
throw PersistenceError.createCrossPlatformLockError(err.message);
}
}
else {
throw err;
}
}
}
sleep(ms) {
return new Promise((resolve) => {
setTimeout(resolve, ms);
});
}
}
export { CrossPlatformLock };
//# sourceMappingURL=CrossPlatformLock.mjs.map
@@ -0,0 +1 @@
{"version":3,"file":"CrossPlatformLock.mjs","sources":["../../src/lock/CrossPlatformLock.ts"],"sourcesContent":[null],"names":["fs"],"mappings":";;;;;;;;AAAA;;;AAGG;AAUH;;AAEG;MACU,iBAAiB,CAAA;AAQ1B,IAAA,WAAA,CACI,YAAoB,EACpB,MAAc,EACd,WAAsC,EAAA;AAEtC,QAAA,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;AACjC,QAAA,IAAI,CAAC,WAAW,GAAG,WAAW,GAAG,WAAW,CAAC,WAAW,GAAG,GAAG,CAAC;AAC/D,QAAA,IAAI,CAAC,UAAU,GAAG,WAAW,GAAG,WAAW,CAAC,UAAU,GAAG,GAAG,CAAC;AAC7D,QAAA,IAAI,CAAC,MAAM,GAAG,M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B,YAAA,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;AAC5B,SAAC,CAAC,CAAC;KACN;AACJ;;;;"}
@@ -0,0 +1,10 @@
/**
* Options for CrossPlatform lock.
*
* retryNumber: Numbers of times we should try to acquire a lock. Defaults to 500.
* retryDelay: Time to wait before trying to retry a lock acquisition. Defaults to 100 ms.
*/
export type CrossPlatformLockOptions = {
retryNumber: number;
retryDelay: number;
};