Skip to content

Commit

Permalink
fix streamSource event emitter memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
maartyman committed Nov 25, 2024
1 parent 66b2c91 commit 3508209
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ export class StreamQuerySources implements IQuerySource {
context: IActionContext,
) {
this.sourcesEventEmitter = new EventEmitter();
this.sourcesEventEmitter.setMaxListeners(Infinity);

Check failure on line 52 in packages/actor-query-source-identify-stream/lib/StreamQuerySources.ts

View workflow job for this annotation

GitHub Actions / lint

Prefer `Number.POSITIVE_INFINITY` over `Infinity`
stream.on('data', (item: IStreamQuerySource) => {
if (item.isAddition) {
const chunk: ISourceWrapper = {
Expand Down Expand Up @@ -144,10 +145,15 @@ export class StreamQuerySources implements IQuerySource {
};
iterator.readable = true;

this.sourcesEventEmitter.on('data', (sourceWrapper: ISourceWrapperSafe) => {
const addSourceToBuffer = (sourceWrapper: ISourceWrapperSafe) => {

Check failure on line 148 in packages/actor-query-source-identify-stream/lib/StreamQuerySources.ts

View workflow job for this annotation

GitHub Actions / lint

Missing return type on function
if (iterator.done) {
this.sourcesEventEmitter.removeListener('data', addSourceToBuffer);
return;
}
buffer.push(sourceWrapper);
iterator.readable = true;
});
}

Check failure on line 155 in packages/actor-query-source-identify-stream/lib/StreamQuerySources.ts

View workflow job for this annotation

GitHub Actions / lint

Missing semicolon
this.sourcesEventEmitter.on('data', addSourceToBuffer);

const unionIterator = new UnionIterator<Bindings>(iterator, { autoStart: false });

Expand Down

0 comments on commit 3508209

Please sign in to comment.