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

Out of memory when snapshotting react-sortable-hoc #3464

Closed
pcvandamcb opened this issue May 4, 2017 · 4 comments
Closed

Out of memory when snapshotting react-sortable-hoc #3464

pcvandamcb opened this issue May 4, 2017 · 4 comments

Comments

@pcvandamcb
Copy link

Jest/Node crashes after a memory leak when trying to snapshot a component that contains an element connected with react-sortable-hoc by @clauderic

I can't tell whether the problem is with the library or with Jest, but my first guess would be that snapshotting should not crash on any component, so I posted it here.

import React from 'react';
import { shallow } from 'enzyme';
import serializer from 'enzyme-to-json/serializer';
import { SortableContainer } from 'react-sortable-hoc';

expect.addSnapshotSerializer(serializer);

const Component = () => (
  <div />
);

const Sortable = SortableContainer(Component);

test('jest crashes on snapshot creation', () => {
  const component = shallow(
    <div>
      <Sortable />
    </div>
  );

  expect(component).toMatchSnapshot();
});

Jest 19.0.2, Node 7.9.0 on macOS 10.12.4

The actual error (which Google tells me is basically out of memory): RangeError: Invalid string length

@pcvandamcb pcvandamcb changed the title Memory leak when snapshotting react-sortable-hoc Out of memory when snapshotting react-sortable-hoc May 4, 2017
@cpojer
Copy link
Member

cpojer commented May 4, 2017

You are right, snapshotting should not crash but the problem here is likely that Jest is inspecting something in the rendered component tree which, when accessed, produces an error. There is not really anything we can do about this and it is probably better to go hunting for the issue in the other library.

@cpojer cpojer closed this as completed May 4, 2017
@jacobrask
Copy link
Contributor

I have the same issue when rendering with Enzyme and React Router. I realize it's not a Jest issue, but could Jest catch OOM and give a better error message than "Invalid string length"?

@sapegin
Copy link

sapegin commented Jul 25, 2017

I’ve spent some time to debug this issue too. I had a react-hotkeys component like this:

<HotKeys attach={window} focused {...rest}>{children}</HotKeys>

The issue could be also reproduced like this:

expect(window).toMatchSnapshot();

More clear error message in this case would be very helpful.

@github-actions
Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 13, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants