If I have the slightest timeout in index.js (main entrypoint), plugin fails with menuItems
error:
Log
Uncaught TypeError: Cannot read properties of null (reading 'menuItems')
at e.exports.pushFullUpdate (uxp://uxp-internal/pluginmanager_scripts.js:2)
at e.exports._pushFullUpdate (uxp://uxp-internal/pluginmanager_scripts.js:2)
at uxp://uxp-internal/pluginmanager_scripts.js:2
at uxp://uxp-internal/runtime_scripts_loader.js:2
pushFullUpdate @ uxp://uxp-internal/p…anager_scripts.js:2
_pushFullUpdate @ uxp://uxp-internal/p…anager_scripts.js:2
(anonymous) @ uxp://uxp-internal/p…anager_scripts.js:2
(anonymous) @ uxp://uxp-internal/r…scripts_loader.js:2
Which is impossible to debug
Minimal example to reproduce:
// index.js
import { entrypoints } from "uxp"
const myFunc = async () => {
return new Promise((resolve) => {
setTimeout(() => {
resolve(true)
}, 50)
})
}
myFunc().then(() => {
entrypoints.setup({
panels: {
"panel1": {
create() {
return new Promise(function(resolve) {
const container = document.createElement("div")
container.className = "root"
container.innerHTML = "<p>PANEL</p>"
document.appendChild(container)
resolve(true)
})
},
menuItems: [{
id: "menuItemId",
label: "menuItem.label",
enabled: false,
checked: false,
}],
},
},
})
console.log("ALL_DONE")
})
ALL_DONE
is logged before the error
If you remove the timeout or make it like 5
ms, then panel loads
At which point menuItems
is null
? Is this expected? What am I missing?