-
Notifications
You must be signed in to change notification settings - Fork 29
Description
Most of the time, the error returned from the layout methods is the somewhat useful syntax error in line N near '...'
.
But I've noticed in this library, for some cases it seems to return somewhat random string results. For example:
// hello
digraph G {
a->b;
->c;
}
When run through this library, the result will be random characters / tofu and not an actual error message.
See for example the attached, which is a modification of the hello world from the README:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>GraphViz WASM</title>
<script src="https://cdn.jsdelivr.net/npm/@hpcc-js/wasm/dist/index.min.js"></script>
<script>
var hpccWasm = window["@hpcc-js/wasm"];
</script>
</head>
<body>
<div id="placeholder"></div>
<div id="placeholder2"></div>
<script>
const dot = `// hello
digraph G {
a->b;
->c;
}`;
// Asynchronous call to layout
hpccWasm.graphviz.layout(dot, "svg", "dot").then(svg => {
const div = document.getElementById("placeholder");
div.innerHTML = svg;
}).catch(e => {
console.log('error from async', e);
});
hpccWasm.graphvizSync().then(graphviz => {
const div = document.getElementById("placeholder2");
// Synchronous call to layout
div.innerHTML = graphviz.layout(dot, "svg", "dot");
}).catch(e => {
console.log('error from sync', e);
});
</script>
</body>
</html>
To verify that GraphViz itself isn't the cause of this problem, I just built the latest graphviz from source and ran that same graph through and it doesn't seem to have a problem with showing an error there.
> dot bad-graph.dot
Error: bad-graph.dot: syntax error in line 4 near '->'
> dot -v
dot - graphviz version 2.47.1~dev.20210316.0544 (20210316.0544)
Any ideas? It seems that wasm.Main.prototype.lastError()
is not set and returning random bytes, but I don't really understand how that part works quite yet