I think I may have found a bug with the character sheet web workers' setAttrs() function. After some point, it seems to stop invoking the callback for setAttrs. Here, I try to invoke the use setAttrs' callback to resolve a Promise. The callback doesn't seem to ever get invoked though. debug ends up getting set to 42, and not 'this is a test'. (() => {
'use strict';
/**
* Promise-wrapped setAttrs.
*/
function _setAttrs(values) {
return new Promise((resolve, reject) => {
setAttrs(values, undefined, resolve);
});
}
on('sheet:opened', () => {
Promise.resolve(42)
.then(value => {
return _setAttrs({
debug: value
});
})
.then(value => {
return _setAttrs({
debug: 11
});
})
.then(value => {
setAttrs({
debug: 'this is a test'
});
})
.catch(err => {
_setAttrs({
debug: err.toString()
});
});
});
})();
Here is the same code without using setAttrs, just to show that the way I'm using Promises isn't the issue. Here, debug is set to 'this is a test' at the end as expected. (() => {
'use strict';
/**
* Promise-wrapped setAttrs.
*/
function _setAttrs(values) {
return new Promise((resolve, reject) => {
resolve();
});
}
on('sheet:opened', () => {
Promise.resolve(42)
.then(value => {
return _setAttrs({
debug: value
});
})
.then(value => {
return _setAttrs({
debug: 11
});
})
.then(value => {
setAttrs({
debug: 'this is a test'
});
})
.catch(err => {
_setAttrs({
debug: err.toString()
});
});
});
})();
After some further testing, it seems like I can invoke the Promises' resolve from outside the setAttrs() callback, but not from inside it. This further confirms that something weird is going on with how things are working inside setAttrs()'s callback.