Acting on child_process.spawn events in Meteor

Hi,

I am running a bash script on Meteor backend and I want to act on ‘close’ event:

            let spw = cp.spawn(script, ['-t', argument], options);
            let endLine = '';
            spw.stdout.on('data', function (data) {
                str = data.toString();
                endLine = str.trim();
            });
            spw.on('close', function (code) {
                const testResult: Result = {
                    job: "xxx",
                    result: "xxx",
                    date: "xxx"
                }
                Results.insert(testResult);
            });
            spw.stderr.on('data', function (data) {
                console.log('stderr: ' + data);
            });

I am receiving the error as follows:

Error: Meteor code must always run within a Fiber. Try wrapping callbacks that you pass to non-Meteor libraries with Meteor.bindEnvironment.

I have looked for a solution and there are plenty suggesting fibers, _wrapasync, but they aren’t related to acting on stream events. What should be the proper pattern here?