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

TypeError: Cannot read properties of undefined (reading 'length') #13

Closed
4 tasks done
trueberryless opened this issue Jan 15, 2025 · 3 comments
Closed
4 tasks done
Labels
💪 phase/solved Post is done

Comments

@trueberryless
Copy link
Contributor

trueberryless commented Jan 15, 2025

Initial checklist

Affected package

[email protected]

Steps to reproduce

Okay, this is very weird, when I try to repro, it works totally fine as you can see here:
https://stackblitz.com/edit/node-zqgpemoq?file=index.js

But I'm using the plugin in this repo and as you can see here the tests are failing, because the plugin throws the error TypeError: Cannot read properties of undefined (reading 'length').
You can also try by cloning the repo, checking out into tests branch, cd .\packages\starlight-spell-checker\tests\fixtures\quotes-throw-error-invalid-content\, pnpm i and running pnpm astro build. (I know this is a VERY BAD example for a repro, but I have no clue why it's just happening in this specific case...

Actual behavior

Plugin fails when smart has only 2 entries with TypeError: Cannot read properties of undefined (reading 'length')

Expected behavior

Plugin should return vfile correctly.

The issue gets fixed, when I add a safety mechanism:

- expected = markers[(stack.length - 1) % markers.length]
+ expected = markers[(stack.length - 1 + markers.length) % markers.length]

Related issues:
#12
#11

Runtime

[email protected]

Package manager

[email protected]

Operating system

Windows 11

Build and bundle tools

Astro

@github-actions github-actions bot added 👋 phase/new Post is being triaged automatically 🤞 phase/open Post is being triaged manually and removed 👋 phase/new Post is being triaged automatically labels Jan 15, 2025
@trueberryless
Copy link
Contributor Author

I'm very sorry @wooorm to be this fricking annoying, but I'm totally lost why it works perfectly in all tests and in the repro but doesn't in my case... 🙏

@wooorm wooorm closed this as completed in 5dc1e0e Jan 16, 2025
@wooorm wooorm added the 💪 phase/solved Post is done label Jan 16, 2025
@wooorm
Copy link
Member

wooorm commented Jan 16, 2025

Thanks!

@github-actions github-actions bot removed the 🤞 phase/open Post is being triaged manually label Jan 16, 2025
@wooorm
Copy link
Member

wooorm commented Jan 16, 2025

Fixed in 6.0.2!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💪 phase/solved Post is done
Development

No branches or pull requests

2 participants