Skip to content

Commit

Permalink
👌 IMPROVE: Show changes stream create task log (#347)
Browse files Browse the repository at this point in the history
  • Loading branch information
fengmk2 authored Oct 27, 2022
1 parent cd5bd92 commit 92350a8
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/nodejs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [16, 18]
node-version: [16, 18, 19]
os: [ubuntu-latest]

steps:
Expand Down
13 changes: 9 additions & 4 deletions app/core/service/ChangesStreamService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,21 +173,26 @@ export class ChangesStreamService extends AbstractService {
const valid = await this.needSync(registry, fullname);
if (valid) {
taskCount++;
const tips = `Sync cause by changes_stream(${registry.changeStream}) update seq: ${seq}`;
try {
await this.packageSyncerService.createTask(fullname, {
const task = await this.packageSyncerService.createTask(fullname, {
authorIp: HOST_NAME,
authorId: 'ChangesStreamService',
registryId: registry.registryId,
skipDependencies: true,
tips: `Sync cause by changes_stream(${registry.changeStream}) update seq: ${seq}`,
tips,
});
this.logger.info('[ChangesStreamService.createTask:success] fullname: %s, task: %s, tips: %s',
fullname, task.id, tips);
} catch (err) {
if (err instanceof RegistryNotMatchError) {
this.logger.warn('[ChangesStreamService.executeSync:skip] %s', err.message);
this.logger.warn('[ChangesStreamService.executeSync:skip] fullname: %s, error: %s, tips: %s',
fullname, err, tips);
continue;
}
// only log error, make sure changes still reading
this.logger.error('[ChangesStreamService.executeSync:error] %s', err);
this.logger.error('[ChangesStreamService.executeSync:error] fullname: %s, error: %s, tips: %s',
fullname, err, tips);
this.logger.error(err);
continue;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,10 @@ describe('test/port/controller/PackageSyncController/createSyncTask.test.ts', ()
assert(res.body.ok === true);
assert(res.body.state === 'waiting');
assert(res.body.id);
await setTimeout(100); // await for sync task started
app.expectLog('[PackageSyncController.createSyncTask:execute-immediately]');
app.expectLog('[PackageSyncController:executeTask:start]');
app.expectLog(', targetName: koa-not-exists,');
await setTimeout(100); // await for sync task started
app.mockAgent().assertNoPendingInterceptors();
});

Expand Down

0 comments on commit 92350a8

Please sign in to comment.