Reactjs: Using libarchivejs to handle 7z files: Archive.open() is freezing and gives no error or results

Viewed 100

I'm trying to use libarchivejs for my reactjs project to handle 7z files.

The package is installed with yarn add libarchive.js. The following code:

import { Archive } from 'libarchive.js/main.js';

Archive.init({
    workerUrl: 'libarchive.js/dist/worker-bundle.js'
});


export const handleFile = async (file) => {
  console.log('file: ', file)
  console.log('_7zOpen !! ')

  const archive = await Archive.open(f);
  console.log('archive: ', archive)

  const filesObject = await archive.getFilesObject();
  console.log("filesObject: ", filesObject)

  const filesArray = await archive.getFilesArray();
  console.log("filesArray: ", filesArray)

  return filesArray
}

This runs, but the console output only print out file and _7zOpen !! and then just stops there without any further response. No error is thrown, and the line console.log('archive: ', archive) never gets executed.

console log output:

file:  File {path: 'CE027001-120011101924-T100.7z', 
name: 'CE027001-120011101924-T100.7z', 
lastModified: 1599377977254, 
lastModifiedDate: Sun Sep 06 2020 16:39:37 GMT+0900, webkitRelativePath: '', …}
lastModified: 1599377977254
lastModifiedDate: Sun Sep 06 2020 16:39:37 GMT+0900 {}
name: "CE027001-120011101924-T100.7z"
path: "CE027001-120011101924-T100.7z"
size: 75602083
type: "application/x-7z-compressed"
webkitRelativePath: ""
[[Prototype]]: File

_7zOpen !! 

I suspect that the Archive object is never really running despite the fact that it is installed and imported with no problem.

What is going on? How can I move forward to debug this issue?

0 Answers
Related