On top of Max's answer, the appropriate usage of the continuation style programming should be to replace the one-off callbacks, not the repetitive callbacks. All await
does is to wait for all its deferrals to complete so it can move on. The following example using node.js
's fs
module to read a large file would reproduce this error:
toread = process.argv[2]
fs = require 'fs'
rs = fs.createReadStream toread
await rs.on 'data', defer content
console.log "content: #{content}"
Now run this script with a huge text file. Since the data
event will fire more than once as the large file content doesn't fit the buffer, it fires multiple times to the generated defer callback, thus giving the same error.
<partial file contents...>
ICED warning: overused deferral at <anonymous> (C:\Users\kk\3.coffee:4)
ICED warning: overused deferral at <anonymous> (C:\Users\kk\3.coffee:4)
ICED warning: overused deferral at <anonymous> (C:\Users\kk\3.coffee:4)
...
In this case, it is wrong to use await/defer
since the content
won't be complete. This is exactly why Max mentioned the presence of this error would usually indicate a code bug. In fact IMO it should throw an error rather than a warning that can be silenced.