kanaverse / kana

Single cell analysis in the browser
https://kanaverse.org/kana/
MIT License
142 stars 12 forks source link

ERROR: "ReferenceError: SharedArrayBuffer is not defined" #262

Open mixiaoluo88 opened 2 days ago

mixiaoluo88 commented 2 days ago

Hi,

Thank you for your efforts in creating such great software. I managed to deploy this app locally using the command docker run -it --rm -p 3000:3000 kana:latest. The Dockerfile is as follows:

FROM node:latest

# Expose the app port
EXPOSE 3000

COPY . /kana
WORKDIR /kana

# Build a static version of the app for deployment
RUN npm i --include=dev --force 
RUN npm dedupe --force 

# build the app
RUN PUBLIC_URL="/kana" npm run build

# Start the app
CMD npm run start

However, I encountered an error message preventing me from performing analysis when I opened the page: image

I look forward to your response. Hongyang Lvy

LTLA commented 2 days ago

kana relies on SharedArrayBuffer to perform multi-threaded analyses, but browsers disable this feature by default for security reasons. We get around this by using a service worker to provide cross-site isolation so that SharedArrayBuffer becomes available.

My guess is that, in your case, the service worker configuration isn't quite working properly; probably something to do with a mismatch between the PUBLIC_URL=/kana and where the app is actually being served. @jkanche would know better, but from what I can see, if you want to mimic our GitHub Pages set-up, there shouldn't be a /kana subdirectory; you should be serving the built app from the root of your web server.

jkanche commented 2 days ago

I agree with @LTLA and also depends on where you are running docker (local laptop vs a remote server), the later might require SSL certificates installed on the server for the aforementioned security reasons. The Dockerfile included in the repo is for hosting the application, If you remove the public url should work locally,

FROM node:latest

# Expose the app port
EXPOSE 3000

COPY . /kana
WORKDIR /kana

# Build a static version of the app for deployment
RUN npm i --include=dev --force 
RUN npm dedupe --force 

# build the app
RUN npm run build

# Start the app
CMD npm run start