I was attempting to implement a SharedArrayBuffer in my Express app:
function setup() {
try {
const a = new SharedArrayBuffer(1);
console.info('SharedArrayBuffer is available.');
} catch (e) {
console.error('SharedArrayBuffer is not available.');
}
}
However, I encountered an error: 'SharedArrayBuffer is not available.'
I have added this to my code:
const app = new Express();
app.use((req, res, next) => {
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
next();
});
I have enabled this Experimental JavaScript shared memory features while testing.
But still, I am getting the error.