Skip to content

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

Closed
@trueberryless

Description

@trueberryless

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions