FjordWarden
FjordWarden16mo ago

Deno hangs on error

Why does Deno hang when XML.parse throws an error?
let text = '<xml><xbrli:xbrl><hi>Hello</hi></xbrli:xbrl></xml>'
import * as XML from "https://deno.land/x/xml/mod.ts"

let parseXml = text => {
try{
return XML.parse(text)
}catch(e){
return null
}
};

parseXml(text)
console.log('ok')
try{
parseXml('fail')
}catch(e){
console.log(e)
}
let text = '<xml><xbrli:xbrl><hi>Hello</hi></xbrli:xbrl></xml>'
import * as XML from "https://deno.land/x/xml/mod.ts"

let parseXml = text => {
try{
return XML.parse(text)
}catch(e){
return null
}
};

parseXml(text)
console.log('ok')
try{
parseXml('fail')
}catch(e){
console.log(e)
}
1 Reply
Leokuma
Leokuma16mo ago
There's already an open issue about that in the lib's repo: https://github.com/lowlighter/xml/issues/28
GitHub
Hangs indefinitely with invalid input · Issue #28 · lowlighter/xml
The following code just hangs forever: import { parse } from 'https://deno.land/x/xml@2.1.1/mod.ts'; parse('A') Or am I doing something wrong here? I'd expect it to throw an error.