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
RangeError: start offset of Int32Array should be a multiple of 4
at new Int32Array (<anonymous>)
at new MetadataBlock (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/single_buffer.js:303:13)
at new MetadataBlock (eval at __decorateStruct (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/memium@0.2.0/node_modules/memium/dist/struct.js:52:24), <anonymous>:6:6)
at SuperBlock.rotateMetadata (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/single_buffer.js:489:30)
at SingleBufferStore.set (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/single_buffer.js:674:33)
at SyncMapTransaction.setSync (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/map.js:20:20)
at SyncMapTransaction.set (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/store.js:24:21)
at WrappedTransaction.set (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/store.js:135:24)
at async StoreFS.commitNew (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/fs.js:905:13)
at async StoreFS.createFile (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/fs.js:452:16)
Context:
Ran into this when some code like the following (which seems to fail while copying my node_modules folder -- can work on a reproduction if the issue doesn't seem obvious):
Note
"Why are you not using fs.cp here?", you might ask. It seems to result in an empty filesystem when copying Passthrough -> SingleBuffer, so I just wrote my own dumb version.
exportconstcopyDir=async(fs: typeof_fs,source: string,dest: string,filter: (path: string)=>boolean=()=>true)=>{constsymlinkQueue: {src: string;dest: string}[]=[];asyncfunctioncopyRecursive(src: string,dst: string){try{constentries=awaitfs.readdir(src,{withFileTypes: true});awaitfs.mkdir(dst,{recursive: true});for(constentryofentries){constsrcPath=path.join(src,entry.name);constsrcRelPath=path.relative(source,srcPath);constdstPath=path.join(dst,entry.name);if(!filter(srcRelPath)){continue;}if(entry.isDirectory()){awaitcopyRecursive(srcPath,dstPath);}elseif(entry.isFile()){constdata=nodeFs.readFileSync(srcRelPath);conststats=nodeFs.statSync(srcRelPath);awaitfs.writeFile(dstPath,data,{encoding: 'utf-8'});// Copy file metadata// console.log('stats', stats)awaitfs.chown(dstPath,stats.uid,stats.gid);awaitfs.chmod(dstPath,stats.mode);awaitfs.utimes(dstPath,stats.atime,stats.mtime);}elseif(entry.isSymbolicLink()){symlinkQueue.push({src: srcPath,dest: dstPath});}}}catch(e){console.error(`Failed to copy ${src} to ${dest}:`,e);throwe;}}asyncfunctionresolveSymlinks(){for(const{ src, dest }ofsymlinkQueue){try{consttarget=awaitfs.readlink(src);constabsoluteTarget=path.resolve(path.dirname(src),target);try{awaitfs.stat(absoluteTarget);awaitfs.symlink(target,dest);}catch{awaitfs.copyFile(absoluteTarget,dest);}}catch(err){console.error(`Failed to copy symlink ${src}:`,err);}}}awaitcopyRecursive(source,dest);awaitresolveSymlinks();}exportconsttakeSnapshot=async(props: Partial<TakeSnapshotProps>={})=>{let{ root, filter }={ ...snapshotDefaults, ...props};constestimateUsed=async(folderPath: string)=>{lettotal=0;constwalk=async(dir: string)=>{constentries=awaitnodePromises.readdir(dir,{withFileTypes: true})for(constentryofentries){constfullPath=path.join(dir,entry.name);conststats=awaitnodePromises.lstat(fullPath);if(entry.isDirectory()){awaitwalk(fullPath);}else{total+=stats.blocks*512;}}};awaitwalk(folderPath);returntotal;};constbuffer=newArrayBuffer((awaitestimateUsed(root)));// ???console.debug('buffer',{size: buffer.byteLength, root });constreadable=awaitresolveMountConfig({backend: Passthrough,fs: nodeFs,prefix: root});constwritable=awaitresolveMountConfig({backend: SingleBuffer, buffer });// TODO: there's probably a better way to do thisconsthostPath='/mnt/host';constsnapshotPath='/mnt/snapshot';mount(hostPath,readable);mount(snapshotPath,writable);awaitreadable.ready()awaitwritable.ready()awaitcopyDir(_fs,hostPath,snapshotPath,filter)returnbuffer;};// ...// await takeSnapshot()
Expectation:
This seems like it should work (and it did somewhere around ~2.0.0 -- or perhaps I broke this), not exactly sure what's going wrong here.
Very brief debugging attempt:
Looks like somehow this.used_bytes for the MetadataBlock isn't divisible by 4 (see second argument).
Not sure if related, but is field alignment correct here?
Stacktrace:
RangeError: start offset of Int32Array should be a multiple of 4 at new Int32Array (<anonymous>) at new MetadataBlock (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/single_buffer.js:303:13) at new MetadataBlock (eval at __decorateStruct (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/memium@0.2.0/node_modules/memium/dist/struct.js:52:24), <anonymous>:6:6) at SuperBlock.rotateMetadata (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/single_buffer.js:489:30) at SingleBufferStore.set (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/single_buffer.js:674:33) at SyncMapTransaction.setSync (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/map.js:20:20) at SyncMapTransaction.set (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/store.js:24:21) at WrappedTransaction.set (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/store.js:135:24) at async StoreFS.commitNew (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/fs.js:905:13) at async StoreFS.createFile (file:///home/theo/dev/ezcodelol/node_modules/.pnpm/@zenfs+core@2.2.2/node_modules/@zenfs/core/dist/backends/store/fs.js:452:16)Context:
Ran into this when some code like the following (which seems to fail while copying my
node_modulesfolder -- can work on a reproduction if the issue doesn't seem obvious):Note
"Why are you not using
fs.cphere?", you might ask. It seems to result in an empty filesystem when copyingPassthrough->SingleBuffer, so I just wrote my own dumb version.Expectation:
This seems like it should work (and it did somewhere around ~2.0.0 -- or perhaps I broke this), not exactly sure what's going wrong here.
Very brief debugging attempt:
Looks like somehow
this.used_bytesfor theMetadataBlockisn't divisible by 4 (see second argument).Not sure if related, but is field alignment correct here?
Example stats of file causing this issue:
failed to write { stats: Stats { dev: 64513, mode: 33204, nlink: 2, uid: 1000, gid: 1000, rdev: 0, blksize: 4096, ino: 86000425, size: 47, blocks: 8, atimeMs: 1746813668894.515, mtimeMs: 1746805215458.8567, ctimeMs: 1746805217720.872, birthtimeMs: 1746805215458.8567 }, data: 'import { assoc } from "../fp";\nexport = assoc;\n' }