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

data-uri break the process with no error #52

Closed
sarvaje opened this issue Sep 6, 2018 · 3 comments
Closed

data-uri break the process with no error #52

sarvaje opened this issue Sep 6, 2018 · 3 comments

Comments

@sarvaje
Copy link

sarvaje commented Sep 6, 2018

When you run this code, the process break without any error.

const datauri = 'data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==';
const Canvas = require('canvas-prebuilt');

const image = new Canvas.Image();

image.onerror = function (e) {
    console.log(e);
}
console.log('before');
image.src = datauri;
console.log('after');

Expected output:

before
Error: error while reading from input stream
after

Current output:

before

If I change to canvas everything works as expected (any 1.6.x version).

It works with version 2.0.0-alpha.13 but I can't use it because it is use in jsdom and they don't support version 2 yet.

Maybe this will be fixed after #51 is done.

@chearon
Copy link
Member

chearon commented Sep 10, 2018

If I change to canvas everything works as expected (any 1.6.x version).

Are you sure? I don't think that was implemented until Automattic/node-canvas#1193. canvas@next or canvas-prebuilt@next

@sarvaje
Copy link
Author

sarvaje commented Sep 10, 2018

This is working fine with version 1.6.11.

But just for the record:

Are you sure? I don't think that was implemented until Automattic/node-canvas#1193. canvas@next or canvas-prebuilt@next

Sorry, I though that src was supported in all the versions, but in fact I was using this code:

const dataURL = require("data-urls");
const data = dataURL('data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==');
const Canvas = require('canvas-prebuilt');

const image = new Canvas.Image();

image.onerror = function (e) {
    console.log(e);
}
console.log('before');
image.source = data.body;
console.log('after');

I was expecting an error, but the script finished suddenly in image.source = data.body.

But as I said, this is an issue from the past :)

Thanks!!

@sarvaje sarvaje closed this as completed Sep 10, 2018
@chearon
Copy link
Member

chearon commented Sep 10, 2018

Oops, you're right, I was thinking of http-style URLs. Glad that fixed it for you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants