in chrome private mode, 'NotReadableError' error when using reader.readAsArrayBuffer(file.slice(0, 1024)), file is geted from indexedDB.
⚠️ This is for issues with the https://developer.chrome.com site, not Chromium itself. If you want to file a bug with Chromium (the open-source project behind Google Chrome and other browsers), please use https://crbug.com.
Describe the bug in chrome private mode, after i store a video in indexedDB, then i get the video file from indexedDB and read it using FileReader Api, it has a 'NotReadableError' error when i use reader.readAsArrayBuffer(file.slice(0, 1024)) . it works well when not in Chrome Incognito Mode.
To Reproduce Steps to reproduce the behavior:
- store a file in indexedDB
- get the file from indexedDB
- new FileReader() and read file chunk by using file.slice(0, chunkSize)
- open page in chrome private mode
- See error
Expected behavior no 'NotReadableError' happen
Screenshots

Desktop (please complete the following information):
- OS: os x
- Browser: chrome
- Version: 100.0.4896.75
Additional context Add any other context about the problem here.
What is meant by private mode?
What is the result of the following?
try {
console.log(await new Response(file.slice(0, 1024)).arrayBuffer());
} catch (e) {
console.error(e);
}
Can you post the relevant code here?
너희들은 미국 연방국법원에 변호사를 보내 고소할꺼야. 자료가 넘 많다
2022년 4월 11일 (월) 01:38, guest271314 @.***>님이 작성:
What is meant by private mode?
What is the result of the following?
try { console.log(await new Response(file.slice(0, 1024)).arrayBuffer()); } catch (e) { console.error(e); }
Can you post the relevant code here?
— Reply to this email directly, view it on GitHub https://github.com/GoogleChrome/developer.chrome.com/issues/2563#issuecomment-1094309636, or unsubscribe https://github.com/notifications/unsubscribe-auth/AYR2FSZD2LFZGQISLFALMZTVEL7Y7ANCNFSM5TAZ3ADQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>
@Im2451soon I am only interested in the code.
private mode meant Chrome Incognito Mode,
try {
console.log(await new Response(file.slice(0, 1024)).arrayBuffer());
} catch (e) {
console.error(e);
}
result is:

What is meant by private mode?
What is the result of the following?
try { console.log(await new Response(file.slice(0, 1024)).arrayBuffer()); } catch (e) { console.error(e); }Can you post the relevant code here?
i write a demo, here is code, copy and save as demo.html and run http-server, then open page in chrome Incognito mode. thank you!
// demo.html
<!DOCTYPE html>
<html>
<head>
<title>demo</title>
</head>
<body>
<h2>step 1: select a file and store in indexedDB</h2>
<input type="file" id="input" />
<h2>step2: get the file from indexedDB and slice file</h2>
<button id="button">get file and slice</button>
<section>
<div>name:</div>
<div id="name">--</div>
<div>size:</div>
<div id="size">--</div>
</section>
</body>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/dexie/3.2.1/dexie.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/uuid/8.3.2/uuid.min.js"></script>
<script type="text/javascript">
class VideoDB extends Dexie {
constructor() {
super('videodb');
this.version(1).stores({
video: 'url' // Primary key and indexed props
});
}
}
const db = new VideoDB();
let lastUrl = '';
document.getElementById('input').addEventListener('change', (e) => {
const [file] = e.target.files;
const name = file.name || Date.now();
lastUrl = uuid.v5(name, uuid.v5.URL);
db.video.add({
url: lastUrl,
file,
});
});
document.getElementById('button').addEventListener('click', async (e) => {
const raw = await db.video.get(lastUrl);
console.log(raw);
const { file, url } = raw;
document.getElementById('name').innerHTML = file?.name;
document.getElementById('size').innerHTML = file?.size;
try {
const ab = await new Response(file.slice(0, 1024)).arrayBuffer();
console.log(ab);
} catch(e) {
console.error(e.message);
}
});
</script>
</html>
If you do something like this you can access the data
const buffer = await file.arrayBuffer();
console.log(buffer);
document.getElementById('name').innerHTML = file?.name;
document.getElementById('size').innerHTML = file?.size;
try {
const ab = buffer.slice(0, 1024);
console.log(ab);
@meiqi502 Substitute using Blob.arrayBuffer() for FileReader and Response() plnkr https://plnkr.co/edit/PqZH1wToPuzPGgEL?preview
@meiqi502 Substitute using
Blob.arrayBuffer()forFileReaderandResponse()plnkr https://plnkr.co/edit/PqZH1wToPuzPGgEL?preview
thank you for your apply!
and i have saw your code, but there is two question:
1、when the file is huge such as > 3Gb, file.arrayBuffer() trigger error:
The requested file could not be read, typically due to permission problems that have occurred after a reference to a file was acquired
2、the point i want to do slice before arraybuffer is memory used. read whole file need to use huge memory.

can i slice the file first and then read arraybuffer? any replay will be appreciated~
Do you have a 3GB file that is exposed on the Web I can test with?
Why is Incognito mode necessary?
Do you have a 3GB file that is exposed on the Web I can test with?
Why is Incognito mode necessary?
sorry i don‘t i met this error and really want to know why, is it normal? or is it a bug? thank you for your apply~
Have you tried navigating to Settings -> Privacy and Security -> Cookies and other site data -> Sites that can always use cookies ->
Blobs are stored various ways https://stackoverflow.com/a/56419176. ArrayBuffer are evidently stored differently on Chromium/Chrome. Using ArrayBuffer might be the solution for Incognito mode with your use case.
is it normal? or is it a bug?
Difficult to make the determination if that is working as intended in Incognito mode. The workaround is using ArrayBuffer via Blob.arrayBuffer().
Have you tried navigating to Settings -> Privacy and Security -> Cookies and other site data -> Sites that can always use cookies -> ?
Blobs are stored various ways https://stackoverflow.com/a/56419176.ArrayBufferare evidently stored differently on Chromium/Chrome. UsingArrayBuffermight be the solution for Incognito mode with your use case.
i have tried setting just now,and it seems nothing change
is it normal? or is it a bug?
Difficult to make the determination if that is working as intended in Incognito mode. The workaround is using
ArrayBufferviaBlob.arrayBuffer().
ok, thanks a lot
Ran into this issue as well. A similar Chromium issue was reported. A workaround (suggested in that issue) of cloning the file before further use worked for me:
const buffer = await file.arrayBuffer();
const clone = new File([buffer], file.name, { type: file.type });