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 'inTable') in v4.0.0 #57

Closed
Tracked by #212
arechsteiner opened this issue Sep 18, 2023 · 25 comments
Closed
Tracked by #212
Labels
👯 no/duplicate Déjà vu 👎 phase/no Post cannot or will not be acted on

Comments

@arechsteiner
Copy link

arechsteiner commented Sep 18, 2023

Affected packages and versions

4.0.0

Link to runnable example

https://github.com/arechsteiner/gfm-bug/blob/main/src/App.tsx#L12

Steps to reproduce

Attempt to render

const test = `hello world \`call' hello world \`call'`

With

<ReactMarkdown remarkPlugins={[remarkGfm]}>
  {test}
</ReactMarkdown>

Expected behavior

Previously this was no issue.

Actual behavior

TypeError: Cannot read properties of undefined (reading 'inTable')

image

Runtime

No response

Package manager

yarn 1

OS

macOS

Build and bundle tools

Vite

@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 Sep 18, 2023
@ChristianMurphy
Copy link
Member

Duplicate of remarkjs/react-markdown#763

@ChristianMurphy ChristianMurphy closed this as not planned Won't fix, can't repro, duplicate, stale Sep 18, 2023
@github-actions

This comment has been minimized.

@github-actions
Copy link

Hi! Thanks for taking the time to contribute!

Because we treat issues as our backlog, we close duplicates to focus our work and not have to touch the same chunk of code for the same reason multiple times. This is also why we may mark something as duplicate that isn’t an exact duplicate but is closely related.

Thanks,
— bb

@ChristianMurphy
Copy link
Member

The updates are making their way through several hundred packages, for now pin the previous major until the new react-markdown major is released

@github-actions github-actions bot added 👎 phase/no Post cannot or will not be acted on and removed 🤞 phase/open Post is being triaged manually labels Sep 18, 2023
@arechsteiner
Copy link
Author

@ChristianMurphy I'm a bit confused, how is this a duplicate of a typescript related issue? This is not a typescript error, this is a runtime error.

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Sep 18, 2023

A major version release is rolling out across all: unified, remark, rehype, and micromark packages.
This includes both type changes (static analysis error) and changes to the parser (potential runtime error) if the major versions are mismatched.

@AshuInsideOut
Copy link

Is this issue fixed yet?

@ChristianMurphy
Copy link
Member

ChristianMurphy commented Sep 25, 2023

@AshuGuptaGamer there is nothing to "fix" it isn't a bug.

The major releases are still rolling out across the remark and mdx projects.
Check if the project you use has a new major update.
If there, is try out the new version.
If not, be patient it takes time to update 500+ packages.

srizvi added a commit to and-voila/labs that referenced this issue Nov 13, 2023
- remark-gfm seems like [this issue has been resolved](remarkjs/remark-gfm#57)
ryanrishi added a commit to ryanrishi/ryanrishi.com that referenced this issue Nov 17, 2023
ryanrishi added a commit to ryanrishi/ryanrishi.com that referenced this issue Nov 21, 2023
* upgrade dependencies

* wip add contentlayer

* wip update links and head tags

* get next-themes working kinda

* create-react-app for next 14

* idk, remove purgecss?

* fix some invalid HTML

* get projects kinda working

* wip add blog to app

* kinda get projects working

* get blog working

* get projects working

* migrate contact page

* migrate 404

* use built-in to transpile modules

see https://nextjs.org/docs/app/api-reference/next-config-js/transpilePackages

* add tailwind back

* misc cleanup

* fix tailwind content dirs

* add blog post layout

* rm more layouts

* fix projects index

* sort projects by date desc

* tweak project card borders

* pull out project item into its own file since I'll maybe use client at some point

* add music page

* kill last layout

* oops add missing import

* add more metadata

* fix date vs. publishedAt

* fix eslint errors

* fixed some MDX components

* use contentlayer for music

* wip add test page

* use remark-gfm@3 since v4 is still getting rolled out

see remarkjs/remark-gfm#57

* update iframe

* rm gray-matter

* upgrade eslint

* rm @types/react-syntax-highlighter because it was causing issues

see react-syntax-highlighter/react-syntax-highlighter#539

* fix Google Analytics

* fix some loudness wars typescript issues

* first successful `yarn build` 🎉

* fix some stuff around slugs

* i uhhhh alright I guess I'm escaping urls in my paths now

* rm dummy next-14 dir

* get cypress in a runnable state

* kill react-spring / reach

* daaaaang framer motion is cool

* add social links to mobile nav

* use new next ESLint plugin

* clean up dependencies

* run eslint

* fix some blog metadata

* fix more metadata

* use FancyH1 for 404

* fix blog post title heading

* add leading-8 to project and blog post pages

* defer to tailwind typography over custom styles

* fix tailwind content path

* fix some more classnames and typography

* fix project card image heights

* minor tweaks to conform w/ Tailwind typography

* change url

* use [role="dialog"] instead of custom CSS selector

* rm deprecated property

* tell cypress it's ok to continue to NEXT_NOT_FOUND errors

* fix music headings tests

* rm double underline from links

* make github percy quiet

* add sharp

* use custom h1 for project page

* lint

* rm dead code

* fix og:image assertion

* add favicon and apple-icon

* rm unused permalink

* fix project image link in head

* add twitter to metadata

* fix issue where I was only taking a screenshot of every other project

* make dividing line in mobile nav dark theme aware

* wait before taking screenshot of mobile nav

* update browserslist

* mv blog heading into page, not layout
@jaswrks
Copy link

jaswrks commented Nov 26, 2023

Parsing error: Cannot set properties of undefined (setting 'inTable') eslint

Still getting this error after updating to:

"@mdx-js/mdx": "^3.0.0",

        "remark": "^15.0.1",
        "remark-directive": "^3.0.0",
        "remark-frontmatter": "^5.0.0",
        "remark-gfm": "^4.0.0",
        "remark-lint": "^9.1.2",
        "remark-mdx-frontmatter": "^4.0.0",
        "remark-mermaidjs": "^6.0.0",
        "remark-preset-lint-recommended": "^6.1.3",
        "remark-preset-prettier": "^2.0.1",
        "remark-smartypants": "^2.0.0",
---
Foo: Bar
---

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

Markup on 2023-11-26 at 01:28:43

@wooorm
Copy link
Member

wooorm commented Nov 26, 2023

You can make a PR to remark-preset-prettier, most likely.

Run npm why remark-gfm and look for who uses the the outdated version.

@JounQin
Copy link
Member

JounQin commented Nov 26, 2023

remark-preset-prettier doesn't have any dependencies.

@jaswrks
Copy link

jaswrks commented Nov 26, 2023

Thanks for much for reviewing. Here's what I got after running npm why remark-gfm. Seems like we aren’t running anything else that depends on remark-gfm and I confirmed v4.0.0 is what we are running from the top-level of node_modules. So far I haven't seen anything nested deeper that is using another version of it.

$ npm why remark-gfm
[email protected]
node_modules/remark-gfm
  remark-gfm@"4.0.0" from the root project
---
Foo: Bar
---

| First Header  | Second Header |
| ------------- | ------------- |
| Content Cell  | Content Cell  |
| Content Cell  | Content Cell  |

Is where we trigger the problem. If I remove remark-gfm from our list of plugins, the problem goes away. Or, if I remove the table markdown the problem also goes away. So it definitely seems like an issue with remark-gfm. I'm not sure why, or where to go from here. I'll be happy to open a PR elsewhere if I find a fix.

@remcohaszing
Copy link
Member

This looks like a screenshot from the VSCode remark extension. I’ve been holding back updating this until remark-lint is updated to the latest unified.

@jaswrks
Copy link

jaswrks commented Nov 26, 2023

Thanks all. This seems to resolve the issue by forcibly overriding in package.json, though it's not something I'm ok with for now, so I may need to roll back to prior version of MDX. The underlying cause seems to be eslint. Specifically, the dependencies declared by these two packages are outdated now. See: https://github.com/mdx-js/eslint-mdx/tree/master/packages

    "overrides": {
        "remark-mdx": "3.0.0",
        "remark-parse": "11.0.0",
        "remark-stringify": "11.0.0",
        "unified": "11.0.4"
    }

juliencrn added a commit to juliencrn/usehooks-ts that referenced this issue Jan 22, 2024
- mdx's `remark-gfm` plugin does not work since its latest major version remarkjs/remark-gfm#57
@rusakovic
Copy link

It is still not fixed, right? And the best approach is

syntax-tree/mdast-util-from-markdown#34 (comment)

Hold on version 3 of remark-gfm, until the next major of react markdown is released

Is it correct?

@remcohaszing
Copy link
Member

It is fixed by now. See https://github.com/remarkjs/react-markdown/releases/tag/9.0.0. The comment you linked precedes that release.

@rusakovic
Copy link

It is fixed by now. See https://github.com/remarkjs/react-markdown/releases/tag/9.0.0. The comment you linked precedes that release.

@remcohaszing Thank you for quick response.

I got this error with "remark-gfm": "4.0.0", and recommendation here contentlayerdev/contentlayer#611 (comment) to check this issue.

Or do we mean different issues?

• "docs/codeblock.mdx": UnexpectedMDXError: Error: Build failed with 1 error:
     _mdx_bundler_entry_point-d295f73f-3987-4c43-b652-df139b3af638.mdx:0:0: ERROR: [plugin: @mdx-js/esbuild] TypeError: Cannot read properties of undefined (reading 'inTable')
         at Object.exitCodeText (file:// /node_modules/.pnpm/[email protected]/node_modules/mdast-util-gfm-table/lib/index.js:123:17)
         at compile (file:// /node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index.js:352:40)
         at fromMarkdown (file:// /node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index.js:187:29)
         at parser (file:// /node_modules/.pnpm/[email protected]/node_modules/remark-parse/lib/index.js:18:12)
         at Function.parse (file:// /node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:273:12)
         at executor (file:// /node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:393:31)
         at new Promise (<anonymous>)
         at Function.process (file:// /node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:380:14)
         at process (file:// /node_modules/.pnpm/@[email protected]/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
         at onload (file:// /node_modules/.pnpm/@[email protected][email protected]/node_modules/@mdx-js/esbuild/lib/index.js:151:22)
         at requestCallbacks.on-load ( /node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1434:28)
         at processTicksAndRejections (node:internal/process/task_queues:95:5)
         at handleRequest ( /node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:729:13)

package.json

     "dependencies": {
    "@radix-ui/react-accordion": "1.1.2",
    "@radix-ui/react-aspect-ratio": "1.0.3",
    "@radix-ui/react-collapsible": "1.0.3",
    "@radix-ui/react-dialog": "1.0.5",
    "@radix-ui/react-dropdown-menu": "2.0.6",
    "@radix-ui/react-icons": "1.3.0",
    "@radix-ui/react-scroll-area": "1.0.5",
    "@radix-ui/react-slot": "1.0.2",
    "@radix-ui/react-tabs": "1.0.4",
    "@radix-ui/react-tooltip": "1.0.7",
    "axios": "1.6.8",
    "class-variance-authority": "0.7.0",
    "clsx": "2.1.0",
    "cmdk": "1.0.0",
    "contentlayer": "0.3.4",
    "jotai": "2.8.0",
    "next": "14.2.2",
    "next-contentlayer": "0.3.4",
    "next-themes": "0.3.0",
    "react": "18.2.0",
    "react-children-utilities": "2.10.0",
    "react-dom": "18.2.0",
    "react-wrap-balancer": "1.1.0",
    "rehype-slug": "6.0.0",
    "sharp": "0.33.3",
    "tailwind-merge": "2.2.2",
    "tailwindcss-animate": "1.0.7",
    "zod": "3.22.4"
  },
  "devDependencies": {
    "@types/node": "20.12.7",
    "@types/react": "18.2.79",
    "@types/react-dom": "18.2.25",
    "autoprefixer": "10.4.19",
    "eslint": "9.0.0",
    "eslint-config-next": "14.2.2",
    "mdast-util-toc": "7.0.0",
    "postcss": "8.4.38",
    "rehype-autolink-headings": "^7.1.0",
    "rehype-pretty-code": "^0.13.1",
    "remark": "15.0.1",
    "remark-code-import": "1.2.0",
    "remark-gfm": "3.0.1",
    "tailwindcss": "3.4.3",
    "typescript": "5.4.5",
    "unist-builder": "4.0.0",
    "unist-util-visit": "5.0.0"
  }
}

@remcohaszing
Copy link
Member

I suggest you run npm ls unified. You should see only one version of unified, ideally 11.

You can try to fix it by removing node_modules and your lockfile, and running npm install.

@rusakovic
Copy link

I suggest you run npm ls unified. You should see only one version of unified, ideally 11.

You can try to fix it by removing node_modules and your lockfile, and running npm install.

Thank you for your patience and help. I added overrides as was suggested here #57 (comment)

It didn't help. But I add '"mdast-util-frontmatter": "2.0.1"' in addition:

  "pnpm": {
    "overrides": {
      "remark-mdx": "3.0.0",
      "unified": "11.0.4",
      "remark-parse": "11.0.0",
      "mdast-util-frontmatter": "2.0.1"
    }
  }

Now it works.

Just for google, if other devs will have the same compatibility issue

Error: Found 1 problems in 10 documents.

 └── Encountered unexpected errors while processing of 1 documents. This is possibly a bug in Contentlayer. Please open an issue.

     • "docs/supabase/env.mdx": UnexpectedMDXError: Error: Build failed with 1 error:
     _mdx_bundler_entry_point-3f5a0ab5-57a4-43a2-a41d-8ff1cd0b0b3d.mdx:0:0: ERROR: [plugin: @mdx-js/esbuild] TypeError: Cannot set properties of undefined (setting 'value')
         at Object.close (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/mdast-util-frontmatter/lib/index.js:69:14)
         at compile (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index.js:337:40)
         at fromMarkdown (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/mdast-util-from-markdown/lib/index.js:173:27)
         at parser (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/remark-parse/lib/index.js:33:12)
         at Function.parse (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:668:12)
         at executor (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:734:40)
         at new Promise (<anonymous>)
         at Function.process (file:// /apps/docs/node_modules/.pnpm/[email protected]/node_modules/unified/lib/index.js:720:47)
         at process (file:// /apps/docs/node_modules/.pnpm/@[email protected]/node_modules/@mdx-js/mdx/lib/util/create-format-aware-processors.js:50:22)
         at onload (file:// /apps/docs/node_modules/.pnpm/@[email protected][email protected]/node_modules/@mdx-js/esbuild/lib/index.js:151:22)
         at requestCallbacks.on-load ( /apps/docs/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:1434:28)
         at processTicksAndRejections (node:internal/process/task_queues:95:5)
         at handleRequest ( /apps/docs/node_modules/.pnpm/[email protected]/node_modules/esbuild/lib/main.js:729:13)


SourceFetchDataError: {
  "_tag": "HandledFetchDataError"
}

@remcohaszing
Copy link
Member

You should never use overrides unless you’re absolutely sure there’s a problem with a library. That’s not the case here. Using overrides means you’re purposefully overriding dependency versions, risking breakage in unforeseen ways.

@typeofweb
Copy link

Should this be reopened?
Downgrading to 3.0.1 fixes the problem for now.

@remcohaszing
Copy link
Member

This is not a bug. If you’re seeing this, it means some of your dependencies are outdated, but not all.

@remarkjs remarkjs locked and limited conversation to collaborators May 5, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
👯 no/duplicate Déjà vu 👎 phase/no Post cannot or will not be acted on
Development

No branches or pull requests

10 participants