Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
vzaidman committed Oct 1, 2024
1 parent 5c017bc commit 4d275d2
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
4 changes: 2 additions & 2 deletions packages/metro-file-map/src/Watcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,14 +315,14 @@ export class Watcher extends EventEmitter {
}
});
await Promise.race([
timeoutPromise,
// timeoutPromise,
creationPromise.then(() => observationPromise),
]);
this._pendingHealthChecks.delete(basename);
// Chain a deletion to the creation promise (which may not have even settled yet!),
// don't await it, and swallow errors. This is just best-effort cleanup.
// $FlowFixMe[unused-promise]
creationPromise.then(() =>
await creationPromise.then(() =>
fs.promises.unlink(healthCheckPath).catch(() => {}),
);
debug('Health check result: %o', result);
Expand Down
13 changes: 7 additions & 6 deletions packages/metro-file-map/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,7 @@ export default class FileMap extends EventEmitter {
if (['ENOENT', 'EACCESS'].includes(e.code)) {
missingFiles.add(relativeFilePath);
} else {
throw e;
// throw e;
}
}),
);
Expand All @@ -736,11 +736,10 @@ export default class FileMap extends EventEmitter {
debug('Visiting %d added/modified files.', promises.length);

this._startupPerfLogger?.point('applyFileDelta_process_start');
try {
await Promise.all(promises);
} finally {
await this._cleanup();
}
await Promise.allSettled(promises).finally(() => {
return this._cleanup();
});

this._startupPerfLogger?.point('applyFileDelta_process_end');
this._startupPerfLogger?.point('applyFileDelta_add_start');
for (const relativeFilePath of missingFiles) {
Expand Down Expand Up @@ -1122,6 +1121,8 @@ export default class FileMap extends EventEmitter {
clearInterval(this._healthCheckInterval);
}

await this._buildPromise;

await Promise.all(this._processedFilesPromises.values());

await this._cleanup();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ describe('Server torn down test', () => {
},
);

// test('symlinks', async () => {
// const symlinkTarget = await fsPromises.readlink(__filename);

// });

test('closing should close all handlers', async () => {
const config = await Metro.loadConfig({
config: require.resolve('../metro.config.js'),
Expand Down

0 comments on commit 4d275d2

Please sign in to comment.