Node: DeprecationWarning: Calling an asynchronous function without callback is deprecated.

Created on 28 Oct 2016  路  8Comments  路  Source: nodejs/node

  • Version: 7.0.0
  • Platform: Windows 10 x64
  • Subsystem: fs

I'm getting this warning:

(node:7512) DeprecationWarning: Calling an asynchronous function without callback is deprecated.

The offending line of the stack trace:

at Object.fs.write (fs.js:698:14)

Using this code:

static write(fileDescriptor, buffer, offset, length, position) {
    return new Promise(function(resolve, reject) {
        fs.write(fileDescriptor, buffer, offset, length, position, function(error, written, buffer) {
            if(error) {
                reject(error);
            }
            else {
                resolve({
                    'written': written,
                    'buffer': buffer,
                });
            }
        });
    });
}

I'm not sure why it is complaining about the callback missing, as there is one provided. Anyone know what I am doing wrong?

fs

Most helpful comment

@cjihrig, @mscdex, and @dnalborczyk - you taught a man to fish today. I used the insanely cool debugger in Node 7.0.0 to see I was using the wrong signature for the content I was sending into my write function. Thanks!

All 8 comments

The calling code could be passing in data of the wrong type. Since you're on Node 7, are you able to step into fs.write() using the Inspector, and see where things go wrong?

@cjihrig I'm a noob, can you point me to information on how to use the Inspector?

What values are you passing to your write() when this message gets triggered?

@cjihrig, @mscdex, and @dnalborczyk - you taught a man to fish today. I used the insanely cool debugger in Node 7.0.0 to see I was using the wrong signature for the content I was sending into my write function. Thanks!

Is there a way to know which script is throwing this warning? I see (node:line-number) but it doesn't help me to understand which of my dependencies is throwing it.

@FezVrasta Yes, there is node --trace-warnings yourscript.js (it's node:pid, not line number)

Thanks! Just pushed to PRs two wd and karma-rollup-preprocessor to get rid of some Node 7 deprecations.

Was this page helpful?
0 / 5 - 0 ratings