Skip to content

Commit d47b403

Browse files
committed
fix(inference): correct Piscina queue-saturation message match in PiiRegexWorkerService
Address review feedback: the service matched 'Task queue is at capacity' but Piscina 5.3.1 throws 'Task queue is at limit', so the saturation branch never fired. Fixed the string in the service and the mock in the test. Piscina does not expose a stable error code, so message matching is the only option; added a comment pinning the verified version. Reviewed-at: elastic#288758 (comment)
1 parent e6c8be3 commit d47b403

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

x-pack/platform/plugins/shared/inference/server/workflow_anonymization/detection/regex_worker_service.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ describe('PiiRegexWorkerService', () => {
126126
service = new PiiRegexWorkerService(createTestConfig(), logger);
127127
jest
128128
.spyOn((service as any).worker, 'run')
129-
.mockRejectedValueOnce(new Error('Task queue is at capacity'));
129+
.mockRejectedValueOnce(new Error('Task queue is at limit'));
130130

131131
await expect(service.run(IP_PAYLOAD)).rejects.toThrow('queue at capacity');
132132
});
@@ -135,7 +135,7 @@ describe('PiiRegexWorkerService', () => {
135135
service = new PiiRegexWorkerService(createTestConfig(), logger);
136136
jest
137137
.spyOn((service as any).worker, 'run')
138-
.mockRejectedValueOnce(new Error('Task queue is at capacity'));
138+
.mockRejectedValueOnce(new Error('Task queue is at limit'));
139139

140140
const results = await service.run(IP_PAYLOAD, 'allow_unsafe');
141141

x-pack/platform/plugins/shared/inference/server/workflow_anonymization/detection/regex_worker_service.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ export class PiiRegexWorkerService {
8888
`PII regex detection task timed out after ${this.config.taskTimeout.asMilliseconds()}ms`
8989
);
9090
}
91-
if (err instanceof Error && err.message === 'Task queue is at capacity') {
91+
// Piscina does not expose a stable error code; match on the message
92+
// (verified against piscina@5.3.1 dist/errors.js TaskQueueAtLimit).
93+
if (err instanceof Error && err.message === 'Task queue is at limit') {
9294
throw new Error(
9395
`PII regex detection rejected: worker queue at capacity (maxQueue=${this.config.maxQueue})`
9496
);

0 commit comments

Comments
 (0)