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
a load error can still trigger ready and idle events #27
Comments
Do you recommend using the |
The chaining API is somewhat safer indeed, since you can call
|
Reproducing here the code given in #26
Not sure what is the problem? A complete test might something like this: var WebKit = require('../');
var expect = require('expect.js');
var fs = require('fs');
var path = require('path');
var async = require('async');
describe.only("ordered png render calls", function suite() {
this.timeout(20000);
var w;
before(function(cb) {
var inst = new WebKit();
inst.init({}, function(err) {
if (err) return cb(err);
w = inst;
cb();
});
});
it("should not stall", function(done) {
var arr = [
"https://www.mezilla.org/en-US/",
"https://www.google.com/",
"https://www.debian.org/"
];
async.eachSeries(arr, function(it, cb) {
var href = it;
var filePath = path.resolve(__dirname, './shots/outN.png');
console.error('---> LOAD', href);
w.load(href, {}, function(err) {
console.error('---> LOAD-COMPLETE'); // <--- callback not called for the second time
if(err) {
console.error('---> LOAD-ERR', err);
cb();
} else {
console.error('---> SETTING-IDLE');
w.once('idle', function() {
w.png(filePath, function(err) {
console.error('---> PNG', href, err);
cb();
});
});
}
});
}, function(err) {
done(err);
});
});
}); And the same problem reproduced in case of 404: var arr = [
"http://www.google.com/asdsad"
"https://www.google.com/"
]; |
Right, it looks the No matter what type of API is used: it('should not stall', function(done) {
var filePath = path.resolve(__dirname, './shots/outX.png');
WebKit().load("http://www.google.com/asdsad").wait('idle').png(filePath, function(err) {
//
}).load("https://www.google.com/").wait('idle').png(filePath, function(err) {
done(); // <---- never hits this line
});
}); |
Simplifying further,
second callback is not called, because there was a failure and that stopped the chain. |
but
does not call second callback either. |
Ok, i'm NULL-ing the loadCallback in the c++ code at a moment it could have been set by a new Load call. |
Fixed by c888b54, and published a new version. Note that it doesn't change the fact that
does not call the second load. |
got it, thank you! |
Especially in the non-chaining API.
See #26 to reproduce.
Is it something to keep or something that should not happen ?
The text was updated successfully, but these errors were encountered: