fix(backend): ESM/CJS interop is sad
Docker Image CI / build-and-push-image (push) Has been cancelled
Maintain Release Merge PR / update-release-pr (push) Has been cancelled
release-please / release-please (push) Has been cancelled
test / test-backend (24.x) (push) Has been cancelled
test / API tests (node env, api-test) (24.x) (push) Has been cancelled
test / puterjs (node env, vitest) (24.x) (push) Has been cancelled

Fix ESM/CJS interop issue in unit tests with a hack that checks the
class name as a string instead of just doing an `instanceof` check. This
is assuming that the "rewriter must be a PermissionRewriter" error I'm
seeing on GitHub is because there are two different "copies" of
PermissionWriter due to ESM/CJS interop issues. If this is not the case,
then you're not reading this commit message on `main`; if this commit is
on `main` then that's exactly what went down.
This commit is contained in:
KernelDeimos
2026-02-17 22:12:24 -05:00
committed by Eric Dubé
parent 05cc4ad477
commit cecb63b372
@@ -1191,7 +1191,10 @@ class PermissionService extends BaseService {
* @param {PermissionRewriter} rewriter - The permission rewriter to register
*/
register_rewriter (rewriter) {
if ( ! (rewriter instanceof PermissionRewriter) ) {
const is_permission_rewriter = rewriter instanceof PermissionRewriter
// Hack for ESM/CJS interop issue in unit tests.
|| rewriter?.constructor?.name === 'PermissionRewriter';
if ( ! is_permission_rewriter ) {
throw new Error('rewriter must be a PermissionRewriter');
}