Skip to content

[bug] tokens.at is not a function #3546

Closed
@gorner

Description

Marked version:
15.0.2

Describe the bug
After upgrading from v14, our app started getting error reports with the following text:

t.at is not a function. (In 't.at(-1)', 't.at' is undefined)
Please report this to https://github.com/markedjs/marked.

... so I am doing as instructed 😛

The immediate stack trace reads:

assets/node_modules/marked/lib/marked.umd.js:1522:0:in `at'
                }
                if (this.state.top && (token = this.tokenizer.paragraph(cutSrc))) {
                    const lastToken = tokens.at(-1);
                    if (lastParagraphClipped && lastToken?.type === 'paragraph') {
                        lastToken.raw += '\n' + token.raw;

To Reproduce
Unclear as this only arose through our error logging. We ended up rolling back the marked upgrade, but if/when we find out more information about a specific reproduction path, we will update.

However our logging indicates this error only occurs on a limited range of older browser versions, including Safari 15.3 and earlier, and Chrome 125 and earlier, and it appears the .at() method is not supported on Safari before v15.4 (though supposedly it's supported in Chrome 92+ making the error there a bit more curious). It's not clear whether Marked still supports these versions as the readme currently only says "not IE11".

Expected behavior
The parsing works as expected / without error.

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions