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

t.slice is not a function #20

Closed
abnerlee opened this issue Jul 23, 2021 · 8 comments
Closed

t.slice is not a function #20

abnerlee opened this issue Jul 23, 2021 · 8 comments

Comments

@abnerlee
Copy link

Hi, we received an error t.slice is not a function in our sentry server. Sorry, I didn't find the TeX script to trigger this issue.

But I guess it happens in

MhchemMethods.Machine = function(parser: TexParser, name: string, machine: string) {
  try {
    let arg = parser.GetArgument(name);
    let data = mhchemParser.go(arg, machine);
    // TODO: Harvest chemical information here from data, test looping through
    //       the array.
    let tex = texify.go(data);
    parser.string = tex + parser.string.substr(parser.i);
    parser.i = 0;
  } catch (err) {
    throw new TexError(err[0], err[1], err.slice(2));
  }
};

where err is not an Array in some cases (maybe Error thrown in some of the logic inside)

@mhchem
Copy link
Owner

mhchem commented Jul 23, 2021

It's a pity you did not find the TeX code to trigger this issue. What version of MathJax are you using? Do you use an external version of mhchem or the integrated one?

@abnerlee
Copy link
Author

MathJax 3.2.0, I'm using the tex-svg-full.js built by MathJax.

From the code, if any unexpected Error throws in

let arg = parser.GetArgument(name);
let data = mhchemParser.go(arg, machine);
let tex = texify.go(data);

Then, err will be an Error type, which do not have the .slice function. Only expected ones (thrown by your code), it would be OK.

@mhchem
Copy link
Owner

mhchem commented Sep 13, 2021

@abnerlee Were you able to find TeX input that triggers the issue?

@abnerlee
Copy link
Author

Sorry, No~ We found it in our sentry server, not from customers' report, so we don't know user's exact input.

@abeeonthemoon
Copy link

Hi!

I had an issue that was similar to this. I am using a library called rehype-mathjax to render my mathjax. Currently rehype-mathjax uses the latest version of mathjax. The issue occurred when I typed \ce in the editor.

Note: When I copy and paste the following equation: \ce{CO2 + C -> 2 CO}, it works perfectly fine. However when I am in the process of typing input, then by the time I type \ce that's when I get this error.

Please let me know if I can provide anything else to present this issue. Thank you.

@wb-joona
Copy link

wb-joona commented Feb 14, 2022

I was able to reproduce this issue with MathJax 3.2.0. It's caused by a missing closing bracket in the input. Try rendering \ce{H2O for example (demo)

The issue is that the caught error is not an array like the catch block in MathJax assumes, but e.g.

{
  id: 'MissingCloseBrace',
  message: 'Missing close brace'
}

which does not have a .slice() method.

@mhchem
Copy link
Owner

mhchem commented Feb 14, 2022

That demo was very helpful. I think the bug is with MhchemConfiguration. See my comments in the MathJax issue linked above.

@dpvc
Copy link

dpvc commented Feb 19, 2022

I have made a PR to MathJax-src that addresses the issue.

@mhchem mhchem closed this as completed Aug 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants