You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There appears to be an issue with xml2js in Bun where execution hangs and does not proceed as expected. When running a simple Node.js application that processes a provided XML file using this library, Bun consistently locks up on the second execution.
Interestingly, this behavior does not occur on the first run after package installation but reliably manifests on subsequent executions. While the exact cause remains unclear, the issue seems to originate from this specific point in execution.
Code Snippet.
constfs=require('node:fs');constxml2js=require('xml2js');constLogger=require('./logger');constconfig=require('../config.json');constlogger=newLogger(config.logging);consttalkgroups=newMap();functionloadTalkgroups(xmlPath){constxmlData=fs.readFileSync(xmlPath,'utf8');constparser=newxml2js.Parser();parser.parseString(xmlData,(err,result)=>{if(err){console.error('Error parsing XML:',err);return;}// Process each alias in the playlistfor(constaliasofresult.playlist.alias){consttalkgroupId=alias.id.find(id=>id.$.type==='talkgroup')?.$?.value;if(talkgroupId){talkgroups.set(talkgroupId,{name: alias.$.name,group: alias.$.group,color: alias.$.color});}}logger.success('Talkgroups',`Loaded ${talkgroups.size} talkgroups from playlist`);});}functiongetTalkgroupInfo(talkgroupId){// Convert talkgroupId to string since XML values are stored as stringsconstid=String(talkgroupId);returntalkgroups.get(id)||{name: 'Unknown Talkgroup',group: 'Unknown Department',color: '0'};}functiongetAllTalkgroups(){returnArray.from(talkgroups.entries()).map(([id,info])=>({
id,
...info}));}module.exports={
loadTalkgroups,
getTalkgroupInfo,
getAllTalkgroups
};
What version of Bun is running?
1.2.2+c1708ea6a
What platform is your computer?
Linux 6.6.62+rpt-rpi-2712 aarch64 unknown
What steps can reproduce the bug?
There appears to be an issue with
xml2js
in Bun where execution hangs and does not proceed as expected. When running a simple Node.js application that processes a provided XML file using this library, Bun consistently locks up on the second execution.Interestingly, this behavior does not occur on the first run after package installation but reliably manifests on subsequent executions. While the exact cause remains unclear, the issue seems to originate from this specific point in execution.
Code Snippet.
I couldn't upload the XML that it's used with through GitHub so I've uploaded it via catbox.moe.
https://files.catbox.moe/m5lzr2.xml
What is the expected behavior?
The XML should be processed successfully and return the talkgroups as specified in the XML file.
[2025-02-10T06:26:33.683Z] [INFO] [Database] Database initialized successfully [2025-02-10T06:26:34.366Z] [INFO] [Discord] Logging into Discord... [2025-02-10T06:26:34.438Z] [SUCCESS] [Discord] Swimtrunks is ready! [2025-02-10T06:26:35.216Z] [SUCCESS] [Talkgroups] Loaded 113 talkgroups from playlist [2025-02-10T06:26:35.217Z] [INFO] [Talkgroups] Loaded talkgroup configurations [2025-02-10T06:26:35.219Z] [INFO] [Processor] Started call processing (5000ms interval) [2025-02-10T06:26:35.429Z] [INFO] [Monitoring] Updated channel description with system stats [2025-02-10T06:26:35.430Z] [INFO] [Monitoring] Started system monitoring (60000ms interval)
Should be returned in console.
What do you see instead?
Instead it hangs at this stage.
[2025-02-10T06:26:33.683Z] [INFO] [Database] Database initialized successfully [2025-02-10T06:26:34.366Z] [INFO] [Discord] Logging into Discord... [2025-02-10T06:26:34.438Z] [SUCCESS] [Discord] Swimtrunks is ready!
Additional information
This is part of my project Swimtrunks, which can be located over at https://github.com/cryptofyre/Swimtrunks
The text was updated successfully, but these errors were encountered: