Oops.
This order works:
let items = await Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true, true)
while (items.length) {
const chunk = items.splice(0, 100)
await Zotero.Items.erase(chunk)
}
await Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID)
for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
await collection.eraseTx()
}
this order fails:
for (const collection of (Zotero.Collections.getByLibrary(Zotero.Libraries.userLibraryID, true) || [])) {
await collection.eraseTx()
}
let items = await Zotero.Items.getAll(Zotero.Libraries.userLibraryID, false, true, true)
while (items.length) {
const chunk = items.splice(0, 100)
await Zotero.Items.erase(chunk)
}
await Zotero.Items.emptyTrash(Zotero.Libraries.userLibraryID)