Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bad state error when using meta.apply and compile with render #2151

Closed
bluwy opened this issue Dec 28, 2023 · 2 comments · Fixed by #2152
Closed

Bad state error when using meta.apply and compile with render #2151

bluwy opened this issue Dec 28, 2023 · 2 comments · Fixed by #2152
Assignees
Labels

Comments

@bluwy
Copy link

bluwy commented Dec 28, 2023

When using the deprecated render API to process sass files (Vite still uses it), and also using meta.apply, it fails with (raw log):

Error: Bad state: Can't access __parent outside of a module.
    at Object.wrapException (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:1252:43)
    at _EvaluateVisitor2._async_evaluate0$_assertInModule$1$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:80473:15)
    at _EvaluateVisitor2._async_evaluate0$_assertInModule$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:80476:19)
    at /Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:81047:34
    at _wrapJsFunctionForAsync_closure.$protected (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:4022:15)
    at _wrapJsFunctionForAsync_closure.call$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:33914:12)
    at _awaitOnObject_closure.call$1 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:33902:32)
    at Object._rootRunUnary (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:4408:18)
    at StaticClosure.<anonymous> (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:115526:16)
    at _CustomZone.runUnary$2$2 (/Users/bjorn/Work/repros/vite-sass-test/node_modules/.pnpm/[email protected]/node_modules/sass/sass.dart.js:35338:39)

Using compileString works fine. I'm not sure if it is intentional that this new feature doesn't work with the deprecated render API, but if so I think that's fair and just checking here.

Here's a repro comparing compileString and render: https://stackblitz.com/edit/stackblitz-starters-tirkhu?file=index.js (run node index.js to see error)

This was originally reported at vitejs/vite#15443

@nex3
Copy link
Contributor

nex3 commented Dec 28, 2023

Interestingly, renderSync() also works here, so it looks like it has something to do with the asynchrony specifically. Thanks for reporting this, I'll take a look.

@nex3 nex3 self-assigned this Dec 28, 2023
@nex3 nex3 added the bug label Dec 28, 2023
nex3 added a commit that referenced this issue Dec 28, 2023
nex3 added a commit that referenced this issue Dec 28, 2023
nex3 added a commit that referenced this issue Dec 28, 2023
@bluwy
Copy link
Author

bluwy commented Dec 29, 2023

Thanks for the quick fix!

lmeysel pushed a commit to lmeysel/dart-sass that referenced this issue Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants