@@ -288,6 +288,25 @@ module.exports = EventEmitter;
|
||||
console.log(' Patched events module for node-rdpjs-2 compatibility')
|
||||
}
|
||||
|
||||
// ── Fix 2c: Windows debug logging for .json load failures ─────────────────────
|
||||
// bare-module is runtime-builtin (not in bundle). Patch the first bundled module
|
||||
// (bare-process/global.js) to wrap Module._extensions['.json'] so we can log the
|
||||
// requested URL and protocol.read result on Windows.
|
||||
if (hosts.some((h) => h.startsWith('win32'))) {
|
||||
const globalKey = resolveKey('node_modules/bare-process/global.js')
|
||||
let globalSrc = readKey(globalKey)
|
||||
if (globalSrc !== null) {
|
||||
let src = globalSrc.toString()
|
||||
const orig = "global.process = require('.')\n"
|
||||
const debugPatch = "global.process = require('.')\n;(function(){try{var Module=require('bare-module');if(Module&&Module._extensions&&Module._extensions['.json']){var _orig=Module._extensions['.json'];Module._extensions['.json']=function(m,s,r){var u=m._url!=null&&(typeof m._url==='string'?m._url:m._url.href);try{process.stderr.write('[holesail .json] url='+String(u)+'\\n')}catch(_){};if(s===null)s=m._protocol.read(m._url);var l=s==null?0:(s&&(s.length!=null?s.length:s.byteLength))||0;try{process.stderr.write('[holesail .json] length='+l+'\\n')}catch(_){};if(typeof s==='string')s=Buffer.from(s);m._source=s;try{m._exports=JSON.parse(s.toString())}catch(e){try{process.stderr.write('[holesail .json] FAIL url='+String(u)+' len='+l+' err='+String(e&&e.message)+'\\n')}catch(_){};throw e}}}}}catch(_){}})();\n"
|
||||
if (src.startsWith(orig) && !src.includes('[holesail .json]')) {
|
||||
src = debugPatch + src.slice(orig.length)
|
||||
bundle.write(globalKey, Buffer.from(src))
|
||||
console.log(' Patched bare-process/global.js for Windows .json debug logging')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── Fix 3: Windows JSON empty-content and path normalization ──────────────────
|
||||
// On Windows the runtime can request .json keys with backslashes or get empty
|
||||
// content for some keys. Ensure every .json entry has valid content and add
|
||||
|
||||
Reference in New Issue
Block a user