Comments (9)
Do you recommend using the chaining
API? Are there any difference?
from node-webkitgtk.
The chaining API is somewhat safer indeed, since you can call
WebKit().load(url1).wait('idle').png(file1).load(url2).wait('idle').png(file2)
rightaway and do not worry about details.
OR you can insert an error handler in between:
WebKit().load(url1).wait('idle').png(file1, function(err) {
// err is any error that happened from implicit init() to load, wait, png
}).load(url2).wait('idle').png(file2, function(err) {
// err is any error that happened from latest load, wait, png
})
from node-webkitgtk.
Reproducing here the code given in #26
gchidnov
In the following code that uses theasync
to print images one after the other, the secondload
callback (marked as '---> LOAD-COMPLETE') is never called:var arr = [ "https://www.mezilla.org/en-US/", "https://www.google.com" ]; 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'); 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); });
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:
e.g.
var arr = [
"http://www.google.com/asdsad"
"https://www.google.com/"
];
from node-webkitgtk.
Right, it looks the load callback function
is never called after the first failure.
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
});
});
from node-webkitgtk.
Simplifying further,
W().load('http://mezilla.fr', function(err) {console.error(err);}).load('http://www.google.com', function(err) {console.error(err);})
second callback is not called, because there was a failure and that stopped the chain.
This is a behavior of chainit, not something specific here, so we must be careful about which API is used.
from node-webkitgtk.
but
var W = require('./')
var inst = new W();
inst.init({}, function(err) {
inst.load('http://mozilla.org', {}, function(err) {
console.error(err);
inst.load('http://mozilla.org', {}, function(err) {console.error(err)})
});
});
does not call second callback either.
from node-webkitgtk.
Ok, i'm NULL-ing the loadCallback in the c++ code at a moment it could have been set by a new Load call.
from node-webkitgtk.
Fixed by c888b54, and published a new version.
Note that it doesn't change the fact that
W().load('http://fsgdfgdfgdfgdferrpr.com', console.error).load('http://localhost', console.log.bind('ok'))
does not call the second load.
from node-webkitgtk.
got it, thank you!
from node-webkitgtk.
Related Issues (20)
- memleak involving WebKitNetworkProcess HOT 1
- faster view initialization with WEBKIT_DISABLE_COMPOSITING_MODE=1 HOT 1
- [doc] @page for setting print margins HOT 1
- run headless with weston HOT 2
- Empty window with transparent background and hanging process under weston HOT 9
- request events should not send all of data-uri by default
- selenium webdriver
- travis in docker HOT 1
- check ulimit and warn if low
- Build Error HOT 1
- tests hang with webkitgtk 2.16 on debian/fedora HOT 2
- webkitgtk loads system extensions ! HOT 2
- support setting print ranges
- when a page is blank, pdf outputs error "Invalid page range"
- N-API !
- npm rebuild does not rebuild webkitgtk
- Do you have problems running tests in Travis CI? HOT 3
- [email protected] install error HOT 2
- Set window position on screen ? HOT 15
- uv and gtk loop integration
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-webkitgtk.