Skip to content

Commit

Permalink
Merge pull request #429 from Inist-CNRS/fix-expand
Browse files Browse the repository at this point in the history
fix: 🐛 avoid server crash
  • Loading branch information
touv authored Nov 7, 2024
2 parents b18a8d2 + 5c9c7ad commit 40cd871
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/core/src/statements/expand.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,13 @@ export default async function expand(data, feed) {
const size = Number(this.getParam('size', 1));
const path = this.getParam('path');
const cacheName = this.getParam('cacheName');

if (this.isFirst()) {
if (!this.store) {
this.store = {};
this.buffer = [[]];
this.bufferIndex = 0;
this.bufferPromises = [[]];
}
if (this.isFirst()) {
if (cacheName && !this.cachePath) {
const location = this.getParam('location');
this.cachePath = resolvePath(location || tmpdir(), 'memory', `expand${cacheName}`);
Expand Down
36 changes: 36 additions & 0 deletions packages/core/test/unKnownPipeline.js
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,42 @@ describe('dispatch through server(s)', () => {
}
});
});

it('with an buggy script', (done) => {
const script = `
[use]
plugin = basics
[assign]
path = value
value = update("value.abstract
", (item) =>
[expand]
size = 10
[expand/transit]
`;
const server = [
'127.0.0.1',
];
const ten = new Upto(10);
let semaphore = true;
ten
.pipe(ezs('dispatch', { script, server }))
.pipe(ezs.catch())
.on('error', (error) => {
assert(error instanceof Error);
if (semaphore) {
semaphore = false;
ten.destroy();
done();
}
});
});

it('with commands in distributed pipeline', (done) => {
const commands = [
{
Expand Down

0 comments on commit 40cd871

Please sign in to comment.