Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fs.writeFile with callback will log: DeprecationWarning: Calling an asynchronous function without callback is deprecated. #12100

Closed
rokyed opened this issue Mar 28, 2017 · 3 comments
Labels
fs Issues and PRs related to the fs subsystem / file system.

Comments

@rokyed
Copy link

rokyed commented Mar 28, 2017

NODE:

node.js v6.7.0

SYSTEM:

Architecture: x86_64
CPU op-mode(s): 32-bit, 64-bit
Byte Order: Little Endian
CPU(s): 4
On-line CPU(s) list: 0-3
Thread(s) per core: 2
Core(s) per socket: 2
Socket(s): 1
NUMA node(s): 1
Vendor ID: AuthenticAMD
CPU family: 21
Model: 19
Model name: AMD A8-6500 APU with Radeon(tm) HD Graphics
Stepping: 1
CPU MHz: 1700.000
CPU max MHz: 3500.0000
CPU min MHz: 1700.0000
BogoMIPS: 6999.72
Virtualization: AMD-V
L1d cache: 16K
L1i cache: 64K
L2 cache: 2048K
NUMA node0 CPU(s): 0-3

OS:

Linux my-name 4.4.0-67-generic #88-Ubuntu SMP Wed Mar 8 16:34:45 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

ERROR:

DeprecationWarning: Calling an asynchronous function without callback is deprecated.

WHEN:

// callback and scope are provided before
fs.writeFile(fileName, myString, (err) => {
	if (err) throw err;

	console.log('=> done  ' + fileName);
	callback.apply(scope, [fileName]);
});
// logically the code follows the structure but names and information are modified due to NDA.
@cjihrig
Copy link
Contributor

cjihrig commented Mar 28, 2017

FWIW, can't reproduce on macOS.

const fs = require('fs');

fs.writeFile(__dirname + '/blah.out', 'hello', (err) => {
	if (err) throw err;
	console.log('done');
});
$ node -v
v6.7.0
$ node foo.js 
done
$ cat blah.out 
hello

@vsemozhetbyt
Copy link
Contributor

vsemozhetbyt commented Mar 28, 2017

@rokyed I also can't reproduce on Windows:

'use strict';

const fs = require('fs');

const fileName = 'test.txt'
const myString = 'abc';
const scope = {};
const callback = () => {};

fs.writeFile(fileName, myString, (err) => {
  if (err) throw err;

  console.log('=> done  ' + fileName);
  callback.apply(scope, [fileName]);
});
> node.exe -v
v6.7.0

> node.exe test.js
=> done  test.txt

> cat test.txt
abc

Are you sure the fs.writeFile() produces this error? Could you provide the error stack trace and a minimal but complete code to reproduce?

@mscdex mscdex added the fs Issues and PRs related to the fs subsystem / file system. label Mar 28, 2017
@silverwind
Copy link
Contributor

Pretty sure the warning isn't happening in the provided code sample. If you have better standalone example, please post it and we'll reopen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
fs Issues and PRs related to the fs subsystem / file system.
Projects
None yet
Development

No branches or pull requests

5 participants