New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

nuclide-watchman-helpers

Package Overview
Dependencies
Maintainers
5
Versions
29
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuclide-watchman-helpers - npm Package Compare versions

Comparing version 0.5.0 to 0.6.0

77

lib/WatchmanClient.js

@@ -50,5 +50,8 @@ /**

this._initWatchmanClient();
this._serializedReconnect = serializeAsyncCall(() =>
this._reconnectClient(),
);
this._serializedReconnect = serializeAsyncCall(() => {
logger.info('Calling _reconnectClient from _serializedReconnect.');
return this._reconnectClient().catch(error =>
logger.error('_reconnectClient failed', error),
);
});
this._subscriptions = new Map();

@@ -101,18 +104,35 @@ }

// TODO(mbolin): What happens if someone calls watchDirectoryRecursive() while
// this method is executing?
async _restoreSubscriptions(): Promise<void> {
const watchSubscriptions = Array.from(this._subscriptions.values());
const numSubscriptions = watchSubscriptions.length;
logger.info(
`Attempting to restore ${numSubscriptions} Watchman subscriptions.`,
);
let numRestored = 0;
await Promise.all(
watchSubscriptions.map(async (subscription: WatchmanSubscription) => {
await this._watchProject(subscription.path);
// We have already missed the change events from the disconnect time,
// watchman could have died, so the last clock result is not valid.
await sleep(WATCHMAN_SETTLE_TIME_MS);
// Register the subscriptions after the filesystem settles.
subscription.options.since = await this._clock(subscription.root);
await this._subscribe(
subscription.root,
subscription.name,
subscription.options,
);
}),
watchSubscriptions.map(
async (subscription: WatchmanSubscription, index: number) => {
// Note that this call to `watchman watch-project` could fail if the
// subscription.path has been unmounted/deleted.
await this._watchProject(subscription.path);
// We have already missed the change events from the disconnect time,
// watchman could have died, so the last clock result is not valid.
await sleep(WATCHMAN_SETTLE_TIME_MS);
// Register the subscriptions after the filesystem settles.
const {name, options, root} = subscription;
subscription.options.since = await this._clock(root);
logger.info(
`Subscribing to ${name}: (${index + 1}/${numSubscriptions})`,
);
await this._subscribe(root, name, options);
++numRestored;
logger.info(
`Subscribed to ${name}: (${numRestored}/${numSubscriptions}) complete.`,
);
},
),
);

@@ -142,9 +162,12 @@ }

}
if (!Array.isArray(response.files)) {
if (response.canceled === true) {
logger.info(`Watch for ${response.root} was deleted.`);
// Ending the client will trigger a reconnect.
this._clientPromise.then(client => client.end());
return;
}
if (Array.isArray(response.files)) {
subscription.emit('change', response.files);
} else if (response.canceled === true) {
logger.info(
`Watch for ${response.root} was deleted: triggering a reconnect.`,
);
// Ending the client will trigger a reconnect.
this._clientPromise.then(client => client.end());
} else {
// TODO(most): use state messages to decide on when to send updates.

@@ -158,5 +181,3 @@ const stateEnter = response['state-enter'];

logger.info(`Subscription state: ${stateMessage}`);
return;
}
subscription.emit('change', response.files);
}

@@ -288,2 +309,8 @@

): Promise<WatchmanSubscription> {
logger.info(
`Creating Watchman subscription ${String(
subscriptionName,
)} under ${watchRoot}`,
JSON.stringify(options),
);
return this._command('subscribe', watchRoot, subscriptionName, options);

@@ -290,0 +317,0 @@ }

@@ -5,3 +5,3 @@ {

"main": "./lib/main.js",
"version": "0.5.0",
"version": "0.6.0",
"description": "Helper methods for interacting with fb-watchman",

@@ -24,4 +24,4 @@ "author": "NEEDS OWNER",

"log4js": "1.1.1",
"nuclide-commons": "0.5.0"
"nuclide-commons": "0.6.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc