stockfish.js icon indicating copy to clipboard operation
stockfish.js copied to clipboard

stockfish.js:18 Uncaught ReferenceError: SharedArrayBuffer is not defined

Open pianoplayerjames opened this issue 4 years ago • 7 comments

I'm getting an error in my console log

Uncaught ReferenceError: SharedArrayBuffer is not defined
    at stockfish.js:18
    at stockfish.js:237
    at INIT_ENGINE (stockfish.js:258)
    at stockfish.js:269

pianoplayerjames avatar Sep 25 '21 01:09 pianoplayerjames

This is likely due to https://web.dev/cross-origin-isolation-guide/

orta avatar Oct 31 '21 14:10 orta

I'm getting an error in my console log

Uncaught ReferenceError: SharedArrayBuffer is not defined
    at stockfish.js:18
    at stockfish.js:237
    at INIT_ENGINE (stockfish.js:258)
    at stockfish.js:269

Did you ever find a solution for this?

GoodestUsername avatar Apr 28 '22 07:04 GoodestUsername

So I was running it through XAMPP and added these lines to the XAMPP config file

Header set Cross-Origin-Embedder-Policy "require-corp" Header set Cross-Origin-Opener-Policy "same-origin"

That seemed to solve the sharedBufferArray error

adityaj2003 avatar Jun 09 '22 22:06 adityaj2003

You can try using an older version like 11.0.0

youbek avatar Apr 28 '23 10:04 youbek

If you are using a locaclhost webpage for this you can put this into a file i called server.js and change foldername-of-websitestuff to the foldername where your files of your website are located and change web.html to the html file of your website, then you can run "node server.js" to run a localhost server where you will not get the error sharedarraybuffer is not definde`const express = require('express'); const path = require('path');

const app = express(); const publicFolderPath = path.join(__dirname, 'foldername-of-websitestuff');

app.use((req, res, next) => { res.set('Cross-Origin-Embedder-Policy', 'require-corp'); res.set('Cross-Origin-Opener-Policy', 'same-origin'); next(); });

app.use(express.static(publicFolderPath));

app.get('/', (req, res) => { res.sendFile(path.join(publicFolderPath, 'web.html')); });

// ... Rest of your server code

app.listen(3000, () => { console.log('Server is running on port 3000'); }); `

guest2424 avatar Jul 01 '23 13:07 guest2424

The downloaded code contains an example that doesn't work in the web browser on the localhost of a Windows computer. You'll get these SharedArrayBuffer errors. Can someone tell if it works on a Mac? (Or does it only work with node.js?)

joopdegroot avatar Jun 25 '24 06:06 joopdegroot