nuclide-watchman-helpers
Advanced tools
Comparing version 0.5.0 to 0.6.0
@@ -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" | ||
} | ||
} |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
25088
564
1
+ Addeddomexception@1.0.1(transitive)
+ Addedevent-target-shim@3.0.1(transitive)
+ Addednuclide-commons@0.6.0(transitive)
+ Addedvscode-jsonrpc@3.3.0(transitive)
+ Addedwebidl-conversions@4.0.2(transitive)
- Removednuclide-commons@0.5.0(transitive)
Updatednuclide-commons@0.6.0