text:
CRA ships with react-scripts version 0.9.5

Today I created a new app using the command
npx create-react-app <app name>
I was trying to use scss in my react app but unfortunately even after installing sass library still scss styles were not getting applied. So I though of checking the versions on package.json and found that react-scripts 0.9.5 was shipped with CRA by default whereas the present stable version is 5.0.1 (as per npm).

When I run this I get
npx create-react-app my-app
Need to install the following packages:
  create-react-app
Ok to proceed? (y) y

You are running `create-react-app` 5.0.0, which is behind the latest release (5.0.1).

We no longer support global installation of Create React App.

Please remove any global installs with one of the following commands:
- npm uninstall -g create-react-app
- yarn global remove create-react-app

The latest instructions for creating a new app can be found here:
https://create-react-app.dev/docs/getting-started/

same command, running old code too... fails early in my case

Note the suggested approach to remove any potentially globally installed apps
It's because the default guidance of npx may use a local version of CRA that you had previously installed. I don't know why the docs suggest that versus the more bulletproof (but network-intensive)
npx create-react-app@latest my-app

This gave me a package.json like this:
{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.16.4",
    "@testing-library/react": "^13.1.1",
    "@testing-library/user-event": "^13.5.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-scripts": "5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

I am performing all these operations on a freshly installed ubuntu(20.04.4 LTS) machine. There are no CRA installed globally.
Upon running this following command
npx create-react-app@latest my-app
I get a note like this, once the installation is completed

But I have the following version installed on my machine

Also the above command gave me a package.json like this:
{
  "name": "my-app",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-scripts": "0.9.5"
  },
  "devDependencies": {},
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }
}

I am also experiencing this issue on a fresh install of Ubuntu 21.10 with npm 8.3.1 and node v16.14.0
package.json dependencies after running npx create-react-app test :
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-scripts": "0.9.5"

I have tried reinstalling, specificying version number, and still replicating the problem.

Apparently, yarn is still able to grab the correct scripts if I use
yarn create react-app test
However seems to be error-prone as I'm getting messages about the cache. (Maybe has something to do with permissions??)

Confirmed -> The errors about cache files are a permissions issue.
No doubt this is caused by the fact that yarn create react-app must be run with the sudo command and functions as a root user/global install on Ubuntu. That means that you will encounter other permissions issue as you continue to build the application and attempt to launch it unless you alter the permissions in accordance with the local user's access.

Hello everyone,
I've been hitting my head to the same problem. I eventually realized that the main problem was me using NodeJS as a snap package and snap packages are a fairly new technology Ubuntu/Ubuntu derivatives use. My main fix was to search for the Nodesource PPAs and install everything via the instructions provided by them.
Please note that VS Code (which I have installed as a snap) requires a restart for the above to work, for it will still search for snaps to work.

1 year after, ( sorry was never see it ) look into your global node_modules folder has a npm package, if it's the case , destroy it ( if you look the yellow message, you will see npx didn't take the good version for npm or/and node

I had the same issue today. I have

Ubuntu 22.04.3 LTS
no create-react-app in global node_modules
node at v20.11.0
npm at 10.2.4
installed by snap npm: /snap/bin/npm

I make it work, my work-around was using nvm by running nvm use v18.9.0 (why 18? I don't know, it was the first number I saw in nvm list output). And then a simple npx create-react-app notes and it start working as expected.

authors: KagemniKarimu SlyderSlash-SNAGE atenie bijankundu bmuenzenmeyer juangtato

repo: facebook/create-react-app


text:
How to use CSS-module in webpack 4.19, React 16.5?

Worse Experience in React. I just installed React and eject When I tried to use css-modules but I was unable because the all webpack.config.dev.js code has changed which was before we configure like modules: true, localIdentName: '[name]_[local]_[hash:base64:5]' but Now this option is disappeared Please give me some expected Guide as possible as with example.
Best regard.

CSS Modules work out of the box in Create React App. If you eject, you're on your own -- sorry.
The webpack documentation would be a great place to start.

Sorry, but in this case CSS modules should work by default in ejected CRA, or it does break an app, and eject is useless

CSS Modules work after ejecting. If they don't please file a new issue.

I solved it couple days before by the old way Which we use like this
test: cssRegex,             exclude: cssModuleRegex,             use: getStyleLoaders({               importLoaders: 1,               modules: true,               localIdentName: '[name]__[local]__[hash:base64:5]'             }),
Include the modules: true,  modules: true, localIdentName: '[name]__[local]__[hash:base64:5]' at line 271 below. It works well As I expected
So Enjoy it Again!

I solved it couple days before by the old way Which we use like this
test: cssRegex,
            exclude: cssModuleRegex,
            use: getStyleLoaders({
              importLoaders: 1,
              modules: true,
              localIdentName: '[name]__[local]__[hash:base64:5]'
            }),

Include the modules: true, modules: true, localIdentName: '[name]__[local]__[hash:base64:5]' at line 271 below. It works well As I expected
So Enjoy it Again!

Thank you @John99Dev .

@John99Dev I was struggling like you with the same issue, because it is supposed to work by default but it's not completely true.
Before this release, we could import the css module from a plain Button.css file, now you have to rename your css file to Button.module.css. It solved the problem for me.

That's works pretty good for me! Thanks

source: gharchive/issue

license: MIT

license_type: permissive

license_source: github-api


text:
Problem with styles in production mode

Is this a bug report? yes
Did you try recovering your dependencies? yes
yarn --version: 1.12.3
Environment
System:
OS: macOS 10.14.2
CPU: x64 Intel(R) Core(TM) i7-6820HQ CPU @ 2.70GHz
Binaries:
Node: 8.11.3 - /usr/local/bin/node
Yarn: 1.12.3 - /usr/local/bin/yarn
npm: 6.4.1 - /usr/local/bin/npm
Browsers:
Chrome: 69.0.3497.100
Safari: 12.0.2
npmPackages:
@types/react: ^16.4.18 => 16.4.18
@types/react-dom: ^16.0.9 => 16.0.9
react: ^16.6.0 => 16.6.0
react-dom: ^16.6.0 => 16.6.0
react-scripts: Not Found
npmGlobalPackages:
create-react-app: Not Found
Steps to Reproduce
I'm not sure how to reproduce it. I noticed this problem too late.
But here is the source code: https://github.com/RaspberryWallet/Frontend
The app has a problem with styles in production mode, and it's working fine in development mode.
Here is what happens in production:
https://www.youtube.com/watch?v=hjzoEjYxymg
I need to refresh the page ~5 times before it shows the proper styles.
The problem occurs in this pages:
(https://github.com/RaspberryWallet/Frontend/blob/master/src/Components/Initialization/Initialization.tsx)
and
https://github.com/RaspberryWallet/Frontend/blob/master/src/Components/Home.tsx
I can't find connections.

Hi @stasbar, that's a very strange situation, I can see why it's frustrating for you. I don't think this is a CRA issue, but I'd like to investigate.
I tried to run the repository, but it needs a back-end configured. If you can create a simpler example repo, I can take a look in more detail. Thanks!

Hi @mrmckeb, thank you for help. I will create mockup server, and let you know when it's ready 😃

Ok, backend is ready for demo.
You can get the Manager.jar from:

Download  jar from release
clone onto demo-ready branch
2.2.git clone -b demo-ready https://github.com/RaspberryWallet/Backend.git && cd Backend
2.3. build jar package with maven mvn package

then start it in mock mode with java -jar Manager-1.0-jar-with-dependencies.jar -mock

Hey @mrmckeb any ideas ?

adding "jss": "^10.0.0-alpha.3" to dependencies solved the problem.
I've no idea what happened 🤣

I'm sorry @stasbar, I was on holidays for a week and just got back - I'm glad you have it sorted out!

authors: mrmckeb stasbar


text:
Incremental Typescript Compilation

With Typescript 3.4, an --incremental flag landed. This greatly speeds up builds. It would be great to be able to take advantage of this improvement. Hopefully, this can be an improvement on #6406, I know everyone is looking forward to TypeScript v3 😛
https://www.typescriptlang.org/docs/handbook/release-notes/typescript-3-4.html
https://devblogs.microsoft.com/typescript/announcing-typescript-3-4/
Here is their example of compile times with and without the flag:

Step
Compile Time

Compile without --incremental
47.54s

First compile with --incremental
52.77s

Subsequent compile with --incremental with API surface change
30.45s

Subsequent compile with --incremental without API surface change
11.49s

This is already supported in fork-ts-checker-webpack-plugin which is what we use to do type checking. This improvement is included in the 3.0 alpha that we have out now. Feel free to try it out to see if you notice any improvements!

authors: ianschmitz stramel


text:
Sidebar with only external links fails

Have you read the Contributing Guidelines on issues?

[X] I have read the Contributing Guidelines on issues.

Prerequisites

[X] I'm using the latest version of Docusaurus.
[X] I have tried the npm run clear or yarn clear command.
[X] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
[X] I have tried creating a repro with https://new.docusaurus.io.
[X] I have read the console error message carefully (if applicable).

Description
Creating a sidebar that has only type: 'link' items in it causes an error.  Error message is: DocSidebarNavbarItem: Sidebar with ID "linksSidebar" doesn't have anything to be linked to.
Reporduction:  https://stackblitz.com/edit/docusaurus-vttzpv?file=sidebars.js
Reproducible demo
https://stackblitz.com/edit/docusaurus-vttzpv?file=sidebars.js
Steps to reproduce
Create a sidebar that looks something like this:
linksSidebar: [
    { type: 'link', label: 'Facebook', href: 'http://www.facebook.com' },
    { type: 'link', label: 'Google', href: 'http://www.google.com' },
    { type: 'link', label: 'Amazon', href: 'http://www.amazon.com' },
  ],

Expected behavior
Sidebar is displayed
Actual behavior
Runtime error
Your environment

Public source code:
Public site URL:
Docusaurus version used:
Environment name and version (e.g. Chrome 89, Node.js 16.4):
Operating system and version (e.g. Ubuntu 20.04.2 LTS):

Self-service

[ ] I'd be willing to fix this bug myself.

That's because you have a navbar item that tries to link to a sidebar:
        {
          type: 'docSidebar',
          sidebarId: 'linksSidebar',
          position: 'right',
          lable: 'External links',
        },

This navbar item must be clickable, but your sidebar contains no page, only external link, so there's no URL the navbar item can link to. The error is on purpose to help you figure out this problem. This is not a bug.
Where do you expect your sidebar to be displayed exactly? On what precise URL is this supposed to be displayed? Since your sidebar contains no doc, it won't be displayed on any of your pages unless you use displayed_sidebar: linksSidebar on another doc.
Having a sidebar full of external links is a weird pattern to use. Please explain your intent.

authors: johnmcase slorber

repo: facebook/docusaurus


text:
li element with particular structure  generate weird html on docusaurus build.

Have you read the Contributing Guidelines on issues?

[X] I have read the Contributing Guidelines on issues.

Prerequisites

[X] I'm using the latest version of Docusaurus.
[X] I have tried the npm run clear or yarn clear command.
[X] I have tried rm -rf node_modules yarn.lock package-lock.json and re-installing packages.
[ ] I have tried creating a repro with https://new.docusaurus.io.
[X] I have read the console error message carefully (if applicable).

Description
Nested li element with a particular structure not generated correctly with docusaurus build.
with jsx code below.
export default function Home() {
  return (

asdf

sibling

  );
}

generated html with docusaurus build is weired.
It generates part of li elements sibling outside of

asdf

sibling

There may be a clearer and smaller reproduction code, but the code that experimentally reduced the range as much as possible is above. (If some elements are removed from the example above, issue do not apear)
Reproducible demo
https://github.com/sanggggg/docusaurus-repro
Steps to reproduce

git clone git@github.com:sanggggg/docusaurus-repro.git
yarn && yarn build
compare /build/index.html with src/index.js

Expected behavior
Not add sibling of li (
) to outside of
 but intended position of jsx.
Actual behavior
Sibling of li (
) is added outside
.
Your environment

Public source code: https://github.com/sanggggg/docusaurus-repro
Public site URL:
Docusaurus version used: 2.1.0
Environment name and version (e.g. Chrome 89, Node.js 16.4): node v16.14.0
Operating system and version (e.g. Ubuntu 20.04.2 LTS): macOS Monterey 12.6

Self-service

[ ] I'd be willing to fix this bug myself.

I made this little script that you can directly run with Node:
const $ = require("react").createElement;
const { minify } = require("html-minifier-terser");

function Home() {
  return $(
    "div", null, $(
      "li", null, $(
        "div", null, $(
          "div", null, $(
            "ul", null, $(
              "li", null, $(
                "li", null, "asdf"
              )
            )
          )
        )
      )
    ),
    $("div", { className: "mock" }, "sibling")
  );
}

const html = require("react-dom/server").renderToString($(Home, null));
console.log("Raw render:");
console.log(html);
console.log("Minified:");
minify(html).then(console.log);

The output looks like:
Raw render:

asdf

sibling

Minified:

asdf

sibling

Thank you for your detailed reply @Josh-Cena.
I didn't know it was a problem with the html-minifier-terser, not the docusaurus. I have also fixed that invalid structure because this is not an appropriate markup syntax.

However, when I unintentionally wrote the above markup, it was too difficult to debug the reason why. IMAO, there should be some error or warning for this invalid syntax, not a silent bug.
I'll continue with this question in html-minifier-terser

authors: Josh-Cena sanggggg


text:
IE11 + Firefox caret position incorrect when returning focus with click

Do you want to request a feature or report a bug?
report a bug
What is the current behavior?
Currently, in IE11 and Firefox, when clicking on an unfocused draftjs editor that has text entered in it, the caret position does not update correctly. The caret returns to the last position the draftjs editor remembered instead of the updating the position when clicking. The same issue occurs if you select text in the editor, unfocus the draftjs editor, and then click on the text in the editor again to focus. When you click on a different position in the editor, the previously selected text is highlighted.
The functionality works correctly in Chrome
If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. You can use this jsfiddle to get started: https://jsfiddle.net/stopachka/m6z0xn4r/.
The issue can be reproduced on the landing page for draftjs.org in IE11 and Firefox.
Caret position not updated

Enter text in the editor
Deselect the editor
Click on a position in the box where you want the caret to appear

Selected text not unselected

Enter text in the editor and select a word
Deselect the editor
Click on a position in the box where you want the caret to appear - the word selected in step 1 is selected again instead of positioning the caret

What is the expected behavior?
The expected behavior is the caret updates to the newly clicked location and previously selected text to be unselected.
Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
The issue affects previous and latest versions of draftjs and did not work correctly in previous versions. The issue appears in IE11 and Firefox.

Some possibly related issues:

https://github.com/facebook/draft-js/issues/612 (Caret focus position incorrect after pasting text in IE10/11)
https://github.com/facebook/draft-js/issues/989 (Lost position of the cursor when editing)

I reviewed the pull request attached to #989 but it does not resolve the issue.
Additionally, the caret position issue occurs in Firefox for both Windows and OSx

I'm seeing this with Chrome too (57.0.2987.133 (64-bit) and Draft-JS (0.10.0).

Ok, did some digging on this one. In fact, I think that FF is possibly behaving correctly according to the code.
When the user focuses back into the contenteditable, two events occur in this order:
topFocus
topSelectionChange
When topFocus fires, it uses the last selectionState of the editor and simply sets focus. That means the window selection should get set to that last selection state of the editor (which is producing the bug we are all seeing).
Any selection event does not propagate because it is now equal to the window selection state:
https://github.com/facebook/draft-js/blob/master/src/component/handlers/edit/editOnSelect.js#L42
However, in Chrome, the selection state of the window at the time that the code above executes is still the original selection state that the user made when they focused into the element. That is why the conditional passes true and the update is propagated to the onChange handler. This makes no sense to me, maybe the maintainers will know more why this is possible.
What I would propose is in editOnFocus, trying to evaluate if the editor's selection state has changed in regards to the current window selection and then setting it accordingly. Of course it would only do this if the current node is what is selected. I'm not entirely sure if there was consideration to keep this responsibility out of the editOnFocus handler. I would assume because this method can be called independent of a topFocus event and it might not have a changed selection.
I'd be willing to hack at this if you guys are open to it.
@flarnie any thoughts?

@sarmstrong did you find any workarounds for this?

I haven't attempted a work around yet. If I was going to attempt something, I would check to see if "hasFocus" has changed in selection state and make sure the the current selection state is inline w/ the current document selection. Given that the editor is the selected node.

I see this same behavior in Edge as well, for what it's worth.
@masayuki-nakano are you aware of any differences between Firefox and Chrome with regards to updating selection state?

I can see that window.getSelection() produces very different results for each of the focus and selectionchange events in Firefox and Chrome, and, in particular when the focus event is dispatched in Chrome the selection, is not yet set.
Test case: http://jsbin.com/sahanirolu/edit?html,js,console,output

If this is caused by the difference, @smaug---- and/or mats might have some ideas. Although, I don't know mats's GitHub account.

In particular, when the focus event is dispatched in Chrome the selection is not yet set.

That sounds like a really weird behavior, like https://github.com/facebook/draft-js/issues/1055#issuecomment-320107175 hinted too, but I can't now find any spec defining when selection should be set.

authors: birtles danbrianwhite guncha masayuki-nakano mattkrick nearwood sarmstrong smaug----

repo: facebook/draft-js

license: mit

license_source: bigquery


text:
Cannot fix SSR issue with editorKey prop

Do you want to request a feature or report a bug?
Report a bug.
What is the current behavior?
Causes bag with data-offset-key:
Warning: React attempted to reuse markup in a container but the checksum was invalid. This generally means that you are using server rendering and the markup generated on the server was not what the client was expecting. React injected new markup to compensate which works but you have lost many of the benefits of server rendering. Instead, figure out why the markup being generated is different on the client or server:
 (client) " data-offset-key="egvuv-0-0" data-react
 (server) " data-offset-key="enh8p-0-0" data-react

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem. You can use this jsfiddle to get started: https://jsfiddle.net/stopachka/m6z0xn4r/.
Just draft-js with SSR. Cannot provide jsfiffle because of it doesn't have SSR (or has?).
What is the expected behavior?
SSR without reuse markup errors.
Which versions of Draft.js, and which browser / OS are affected by this issue? Did this work in previous versions of Draft.js?
0.10.1

Hi @cassIn - are you passing in the 'data-offset-key' to Draft as a prop? This is how to fix the issue with SSR. Please see the example that demonstrates this. If you are already passing it in and still getting this error then please reopen and we can look into it.

Also thanks for using the latest version of Draft! :)

Hi @flarnie what's you mean by passing in the 'data-offset-key' to Draft as a prop? I don't see any data-offset-key props in the demonstrate example.
And as I followed the example, construct an emptyContentState, the data-offset-key error is disappear, but then every time i try to input or focus on editor, i got a new error:

Thanks for help:)

https://github.com/facebook/draft-js/blob/master/examples/draft-0-10-0/universal/editor.js#L32

Hey @flarnie, I have an app that passes editorKey to all editors, yet I'm still getting the rehydration warning with the data-offset-key.
It only seems to happen with editors that have an empty initial state. I have two editors, one for the thread detail with lots of data and one for the chat input which is empty, and only the chat input one doesn't rehydrate correctly.
I verified this by logging in my custom <Editor /> component that I use everywhere:
class Editor extends Component {
  render() {
    console.log(this.props.editorKey);
    console.log(convertToRaw(this.props.editorState.getCurrentContent()));

    return <DraftEditor editorState={this.props.editorState} editorKey={this.props.editorKey} />
  }
}

This gives these logs on the server:

and these logs on the client:

Notice how the two editors have different editorKeys which are the same across server and client, but also notice how the React warning data-offset-key references the block key of the chat input editor with no content.
When I remove the empty editor (the chat input), no rehydration warning is logged. (in case that makes a difference, I generate that empty initial state with EditorState.createWithContent(ContentState.createFromText('')))
It'd be great to reopen this issue because I can't seem to find the reason behind this rehydration warning. I'm also using the draft-js-plugins editor in case that's relevant.

Thanks for all the details @mxstbr! Let's reopen this. I should have time to investigate more tomorrow.

Awesome, thank you @flarnie!

@mxstbr I was able to reproduce the issue, and I think the reason is that the empty EditorState is being created fresh on the server, and then created fresh again on the client.
There is an example of SSR in our github repo, and it carefully uses the same data for the empty EditorState on both server on client -
https://github.com/facebook/draft-js/tree/master/examples/draft-0-10-0/universal
I think that if the block keys are different, Draft will think they are different content and re-render, even though you and I know they are both just a block with an empty string.
We could try to force Draft to avoid re-rendering and merge the block keys if their text and entity data is the same. I would rather not because it adds complexity, and this seems solvable if you create a reusable emptyContentState like in the example.
Hope that is helpful!

Ohh that makes total sense, sorry for the false alarm. Thank you so much for digging into this @flarnie, much much appreciated!

authors: cassln flarnie hulufei mxstbr pofigizm


text:
Problem with replaceText Modifier function

Do you want to request a feature or report a bug?
I would like to understand the behavior of the Modifier's replaceText function.
What is the current behavior?
on editorState change I have a piece of code that is responsible for substituting a piece of text with an entity when some conditions are met.
The code is as follows:
`
const replaceString = (editorState, setEditorState) => {
const contentState = editorState.getCurrentContent();
const selectionState = editorState.getSelection();
const block = contentState.getBlockForKey(selectionState.getAnchorKey())
const blockAsArray = block.getText().split(' ');
const lastWord = blockAsArray.pop();
if (lastWord.startsWith('@*') || lastWord.startsWith('#*') || lastWord.startsWith('$*') || lastWord.endsWith('*')) {

    const entity = contentState.createEntity(
        "MENTION",
        "MUTABLE",
        {nature: 'remedy', lastWord}
    );

    const entityKey = entity.getLastCreatedEntityKey();

    const newContentState = Modifier.replaceText(
        contentState,
        selectionState.merge({
            anchorOffset: selectionState.getEndOffset() - lastWord.length,
            focusOffset: selectionState.getEndOffset()
        }),
        lastWord,
        [getInlineStyle(lastWord[0], editorState)],
        entityKey
    );

    editorState = EditorState.push(
        editorState,
        newContentState
    );
}

setEditorState(editorState)

}
const getInlineStyle = (type, editorState) => {
switch (type) {
case '@':
return "REMEDY";
case '#':
return "FAMILY";
default:
return editorState.getCurrentInlineStyle();
}
}
const defaultStyle = {
padding: "5px 10px",
color: "white",
fontWeight: "bold",
borderRadius: "10px",
textDecoration: "none"
}
export const styleMap = {
'REMEDY': {
...defaultStyle,
backgroundColor: "green"
},
'FAMILY': {
...defaultStyle,
backgroundColor: "blue"
},
};
`
What it says is that when an user types a word that meets the conditions in the if statement that word has to be replaced with an entity that has a specific style. It kinda works since the entity substitution is perfect but I have a problem with the styles affecting also words not meeting the above mentioned conditions as you can see in the attached files.  Why does not the replaceText function affect only the selectionRange when it comes to style? As I said, it works perfectly with the text-entity substitution.

https://pastebin.com/m4BV1Z0c
Here you can see the code way better

https://stackoverflow.com/questions/72186286/draft-js-add-entity-on-editorstate-change

`const contentState = editorState.getCurrentContent();
const selectionState = editorState.getSelection();
const block = contentState.getBlockForKey(selectionState.getFocusKey());
const contentStateWithEntity = contentState.createEntity("MENTION", "IMMUTABLE", { username: user.userName });
const entityKey = contentStateWithEntity.getLastCreatedEntityKey();

if (block.getText().indexOf(searchTextRef.current) !== -1) {
  const replacedContentState = Modifier.replaceText(
    contentState,
    new SelectionState({
      anchorKey: block.getKey(),
      anchorOffset: selectionState.getEndOffset() - searchTextRef.current.length,
      focusKey: block.getKey(),
      focusOffset: selectionState.getEndOffset(),
    }),
    `{${user.userName ?? ""}} `,
    editorState.getCurrentInlineStyle(),
    entityKey
  );

  const newEditorState = EditorState.push(editorState, replacedContentState, "replace-text" as EditorChangeType);
  const newEditorStateWithFocusEnd = EditorState.moveFocusToEnd(newEditorState);
  setEditorState(newEditorStateWithFocusEnd);
  searchTextRef.current = "";
}`

const contentState = editorState.getCurrentContent();     const selectionState = editorState.getSelection();     const block = contentState.getBlockForKey(selectionState.getFocusKey());     const contentStateWithEntity = contentState.createEntity("MENTION", "IMMUTABLE", { username: user.userName });     const entityKey = contentStateWithEntity.getLastCreatedEntityKey();     if (block.getText().indexOf(searchTextRef.current) !== -1) {       const replacedContentState = Modifier.replaceText(         contentState,         new SelectionState({           anchorKey: block.getKey(),           anchorOffset: selectionState.getEndOffset() - searchTextRef.current.length,           focusKey: block.getKey(),           focusOffset: selectionState.getEndOffset(),         }),        {${user.userName ?? ""}} ,         editorState.getCurrentInlineStyle(),         entityKey       );       const newEditorState = EditorState.push(editorState, replacedContentState, "replace-text" as EditorChangeType);       const newEditorStateWithFocusEnd = EditorState.moveFocusToEnd(newEditorState);       setEditorState(newEditorStateWithFocusEnd);       searchTextRef.current = "";     }

authors: alessio-de-padova rrijvy


text:
Flow is trying to parse JSON files as JS

A small repo to demonstrate: https://github.com/grncdr/flowtest, running flow status produces the following output:
src/wat.json:1
  1: []
     ^ Unexpected token [

Found 1 error

This happens on the current master: 079271416e89552d23f903ede11c93592ab5f149, I don't know when it was introduced. It currently breaks flow for most any project using a non-trivial amount of npm packages, as these often have static JSON files for test fixtures and whatnot that flow will now find and break on.
Other than that, the intersection & union type fixes in master are awesome! Keep up the great work on Flow! :heart: :heart:

Still happening with the 0.22 release.

0.21 was okay i only got this problem on 0.22

A temporary solution is to ignore the JSON files:
[ignore]
.*/node_modules/.*\.json$

@jamiter unfortunately that seems to cause flow to ignore package.json files, which then causes any modules that make use  of the "main" field in package.json to be unresolvable.

for reference this was the regex I ended up with in my [ignore]:
.*\(lib\|src\|test\|builtin-modules\|binary-extensions\|faker\|spdx\).*\.json

(as far as I can tell Ocaml regexps don't support negative look-behind)

Yep. 0.21 worked fine. 0.22 is b0rked.  The only work-around I can find is what @grncdr suggests: explicitly ignoring all of the json files in node_modules/ except package.json files.

@grncdr, thank you! That explained those unresolvable errors! (Duh) Finally have it all working again. This bug of course still needs to be fixed.

FYI: I just landed https://github.com/facebook/flow/pull/1436 -- which lets Flow parse JSON files that have toplevel array structures (rather than just toplevel object structures).
Based on the error in the OP here, I think that should fix the error that caused that issue!

so we're now compliant with RFC 4627 (the original JSON RFC), thanks!
but we're not with RFC 7159. the latter allows false / null / true / object / array / number / string.
we don't support false, true, null, number or string yet but I think we need to. gonna reopen to track for myself.

@jamiter unfortunately none of these absurd workarounds work if you use a module with a name like owasp-password-strength-test

@jedwards1211, it indeed is not an ideal solution, but they are working on a fix. You can tweak the regex a little to make it work for you. This should solve your issue:
.*/node_modules/.*/\(lib\|test\).*\.json$

The extra slash will make sure that lib or test are directory names within the package.

@eyko Yeah, in that case your best bet is to add a pattern targeting those files to the [ignore] section of your .flowconfig. We're looking into fixes that would require zero user intervention as well.

You might also consider opening an issue with those module authors, informing them that they are including tests in their npm package, which they probably didn't intend to do.

I am getting a related error for malformed JSON, e.g.
➜  isomorphic-webpack git:(master) ✗ flow version
Flow, a static type checker for JavaScript, version 0.34.0
➜  isomorphic-webpack git:(master) ✗ flow
node_modules/conventional-changelog-core/test/fixtures/_malformation.json:1
  1:
     ^ Unexpected end of input

Found 1 error

In this case, node_modules/conventional-changelog-core/test/fixtures/_malformation.json is just an empty file.

@gajus An empty string is invalid JSON, so that error message is accurate and not completely relevant to this issue. Though there is the separate question of whether it's useful for Flow to report that specific case. You might be interested in this issue: https://github.com/facebook/flow/issues/2364

authors: AgentME arypurnomoz gajus grncdr jamiter jedwards1211 jeffmo mroch samwgoldman unscriptable

repo: facebook/flow


text:
Validation silently failing for libs that export types

Assuming I have the following file in my "/flow" directory (which is under [libs] in my .flowconfig):
// @flow
type Foo = {
  bar : strng,
};

Clearly I have a typo, and the type "strng" is not actually defined anywhere.
Normally, when I run flow validation, I'd expect to get the error: identifier `strng`. Could not resolve name.
However, if the file is instead:
// @flow
type Foo = {
  bar : strng,
};
export type Baz = {};

Flow validation passes successfully and shows no errors, despite the typo.
It appears that at that point, any variable throughout my codebase annotated with Foo will accept any value, of any type, for the bar property.
This all means validation is essentially silently failing.
It's very strange that this only seems to be happening when I have an exported type in the same lib
file as the typo (even if it's not the broken type itself that's exported).
Flow version: 0.42.0.
If my full flowconfig could be of use, I'd be happy to attach it (for the most part, though, it's just the standard config that React Native generates).

I take it nobody has any ideas for why this might be happening, or how it could be solved?

Hey @Rovack
Some thoughts about what might be happening here:
I'm not sure why you need the export type Baz... to run into this issue. I was able to do it without that line.
Flow doesn't type check library definitions-- it trusts that they are correct. When Flow saw you mention some type strng, it tried to find where it was defined. I bet that flow just defaulted to any when it couldn't find what strng meant.
Maybe it would be possible to add a warning when this happens. @ballardrog, what do you think?

When I was reproducing this locally, I noticed that the error does show up over the persistent connection, even though it doesn't show up in the CLI. (Also, I didn't need the export type Baz..., either.)
I'm all for having this show up as a type error in the CLI, although there might be a reason for it being this way that I just don't know about.
cc @samwgoldman

@ballardrog @samwgoldman So, 6 weeks later, is it safe to assume there is no significant reason? :)
It would be really great if this could be fixed, since as it stands we've encountered many cases where type errors existed (and in some cases many errors, where the non-existent type was part of a larger union type), but we failed to discover them for weeks/months, until a minor typo happened to be noticed and fixed.

@jbrown215 Hi, I ran into this issue today in a project I work on, and it was indeed triggered by the presence of export for me too. I created a minimal test case reproducing the issue at https://github.com/mwiencek/flow-issue-4466

This should now error


text:
Depth subtyping doesn't support arrays?

example
// Putting + in front of a and b removes two errors for some reason,
// but I don't necessarily want the original objects to be immutable.

// Specific type
type Specific = { a: number, b: string };

// Either type
type NotSpecific = { +[key: string]: number | string };

// function that accepts objects of either type
type ComponentProps = {
  data: Array<NotSpecific>
};
const component = (props: ComponentProps) => { /* do nothing */ };

// object conforming with specific types
const exampleData: Specific = { a: 1, b: 'two' };

// works without arrays
const exampleData2: NotSpecific = exampleData;

// works
// array created inline
component({
  data: [exampleData]
});

// works
// array of inferred types (how is this different than the next example?)
const exampleArray: Array<*> = [exampleData];
component({
  data: exampleArray
});

// doesn't work
// array of specific types
const exampleArray2: Array<Specific> = [exampleData];
component({
  data: exampleArray2
});

I am trying to use the last example here. I have an array of objects of a specific type (e.g. { a: number, b: string }. I want to pass them as a prop to a component that accepts an array of any objects, as long as the values are number or string; it doesn't matter what the key is.
This works if the array is inline or inferred (I must be confused as to what the * means, because I thought it meant it would grab the type from the code, in this case exampleData). But it does not work if the type is declared, even though it works without arrays.
That is to say:
// works
const exampleData: Specific = { a: 1, b: 'two' };
const exampleData2: NotSpecific = exampleData;

// doesn't work
const exampleArray: Array<Specific> = [exampleData];
const exampleArray2: Array<NotSpecific> = exampleArray;

I'm not having any luck using +Array or Array<+Type> to state that the array is covariant, but really I'm not sure what I'm supposed to be doing here to make this work.

You can use the undocumented $ReadOnlyArray<T> instead of Array<T> and your errors go away:
type ComponentProps = {
  data: $ReadOnlyArray<NotSpecific>
};

undocumented

I suppose that explains it.
I found that doing [].concat(specificTypedArray) fixed my problem, and I imagine it is similar to depth subtyping, wherein manipulating a passed object's parameter also manipulates the original object of a specific type to a possibly erroneous value. Arrays being handled much the same way as objects, as pointers, would have the original array contain an erroneously typed object.
I propose $ReadOnlyArray be mentioned on the depth subtyping documentation. This was a real headache.

Why was this closed if $ReadOnlyArray is not yet documented?

PRs welcome

@reyronald because flow is a hobby project not maintained by professionals.

@mrkev Will do, can you re-open the issue then ?

For completeness, here is a link to my Stack Overflow question and answer that described in detail some related error messages, how $ReadOnlyArray solves them, and other workarounds:

Flow doesn’t let me pass Array<A> to Array<A | B> (array of subtypes to array of supertypes)

There was also another question on this topic, Flow Array type fails on subset of that type. Hopefully, users will no longer need to read either question now that the documentation has been added.

@roryokane Wow, you should've opened this PR yourself! 😅  Thank you for your engagement and your thorough reviews!
👍 👍 !

authors: CharlesStover jcready mrkev reyronald roryokane


text:
Can't return anything when returning Class and T is a union

Flow version: tested with 0.89.0 and 0.92.1
With this code:
type MyUnion = ArrayBuffer | Uint8Array;
function foo<T: MyUnion>(x: T): Class<T> {
  if (x instanceof ArrayBuffer)
    return ArrayBuffer;
  return Uint8Array;
}

2 errors occur:
6:   	return ArrayBuffer;
             ^ Cannot return `ArrayBuffer` because `ArrayBuffer` [1] is incompatible with `T` [2].
  References:
  [LIB] ..//static/v0.92.1/flowlib/core.js:647: declare class ArrayBuffer {
                                                              ^ [1]
  4: function foo<T: MyUnion>(x: T): Class<T> {
                                           ^ [2]

7:   return Uint8Array;
            ^ Cannot return `Uint8Array` because `Uint8Array` [1] is incompatible with `T` [2].
  References:
  [LIB] ..//static/v0.92.1/flowlib/core.js:722: declare class Uint8Array extends $TypedArray {}
                                                              ^ [1]
  4: function foo<T: MyUnion>(x: T): Class<T> {
                                           ^ [2]

Interestingly, the function still works as intended when called:
(foo(new Uint8Array([])): Class<ArrayBuffer>); // Error, which is normal, we want that
(foo(new Uint8Array([])): Class<Uint8Array>); // Success

Here is a Try-Flow link if you want to have a look.
I've seen a few similar looking issues where there is a Class<T> and T is a Union type, it looks to me like flow wants T to be a MyUnion instead of being a type that fits this union. Did I miss something? Maybe there a $OneOf<MyUnion> utility function somewhere that could help?

It looks like it has nothing to do with Class<T>. Generics typed with a union seem to be the cause. Here is a smaller snippet:
class A{};
class B{};

const foo = <T: (A | B)>(x: T): T => (x instanceof A) ? new A() : new B();

(foo(new B()): A); // Error, which is normal, we want that
(foo(new B()): B); // Success

Try-Flow link

This is an error because you are saying that your function returns something of the same type as its input, but this is in fact not the case. The annotation T : (A | B) means that the function is generic over any T that is a subtype of (A | B), and you want it to return something of the same type as the T you instantiate it with. However, the function as written only ever returns A or B; no matter what T is. So if T is an instance of some class C that subclasses A, you won't return  C from your function as required by the type signature. This is why you have a type error here.

@dsainati1 My bad, shouldn't have used classes. Let's try that again. Here is an even smaller example:
const foo = <T: string | number>(x: T): T => '' + x; // No errors, probably shouldn't fail before someone calls it anyway

(foo(4): string); // Fails because it expects foo<number> to return number, not because foo is wrong
(foo(4): number); // There should be an error caused by this call

Try-Flow link
I'm mostly wondering why flow doesn't freak out; it does react when only returning empty string or when removing the string | number constraint.

The logic above still applies. If foo is instantiated with empty as T, returning a string will cause your function annotation to be a type-error, since string is not a subtype of empty.

Exactly, and if you call foo(), flow does emit an error and everything is fine. If you call foo(4) however, flow seems to think the function will return a number somehow.
foo doesn't abide by its own contract, it can't, and flow doesn't print an error to tell about it. Returning '' instead of '' + x, will make flow print an appropriate error. Removing the constraint on T will also result in the expected error.

Ah I see what you are saying. The issue here is that Flow doesn't infer generic types, so we defer the error until foo gets used in an incorrect manner.

Yeah, I figured trying to guess what a generic was going to end-up being before seeing a call could very easily turn into a giant halting-problem-shaped headache. But it looks like, when a generic is typed, flow tries.
Here it ends up typing the generic argument (x)  with whatever the constraint is (string | number), it then sees '' + x and interprets it as string + (string | number) and stop there since it can't solve this without any additional info. We know '' + x will always return a string, but all flow sees is a BinaryExpression between a string and a string | number and someone wisely chose not to try all branches.
So... is there a way to ask flow to delay the typing until foo gets called and it has all the information? Like some kind of $ExactlyOneOf<string | number, T> utility type? $Keys and $Values seem to create unions, but I can't see how to break them apart or assemble them selectively.

I don't know exactly what your usecase is, but perhaps you are looking for function overloading? Something like defining
declare function foo(x: number) : number;
declare function foo(x: string) : string;

(foo(3) : number);
(foo("string") : string);
(foo(true) : bool);

Hey! I didn't know you could declare something twice with different types, neat. I'll see what I can do to apply it (lots of things to type). Thank you!


text:
Merging two variables with same indexer does not work

Flow version: 0.111
//@flow
type Indexed = { [string]: number };
const x: Indexed = {foo: 3};
const y: Indexed = {bar: 5}

const z: Indexed = {...x, ...y};

Try here
Expected behavior
I would have expected that the assignment to z works because all indexers are the same so the new variable should also work.
Actual behavior
Cannot determine a type for object literal [1]. `Indexed` [2] cannot be spread because the indexer string [3] may overwrite properties with explicit keys in a way that Flow cannot track. Can you spread `Indexed` [2] first or remove the indexer?

on my radar. trying to fix + put out in a patch

We also experience this problem in graphql-js, see:
https://github.com/graphql/graphql-js/pull/2251/files#diff-a2222d77ff884acdf97c5f295babf27c

There's diffs up for it, but won't make it in until 113

Just checking: This didn’t get into 113, did it?

No, still waiting for review
On Wed, Dec 4, 2019 at 11:02 AM Simon Lydell notifications@github.com
wrote:

Just checking: This didn’t get into 113, did it?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
https://github.com/facebook/flow/issues/8178?email_source=notifications&email_token=ACBH3T2VUBOVRTQF75VGA5TQW7ICFA5CNFSM4JJAJN52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEF5QPAA#issuecomment-561710976,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/ACBH3TZHZAM3UPXVHZG7UQDQW7ICFANCNFSM4JJAJN5Q
.

--
Sent from Gmail Mobile

I'm closing this myself since it has been fixed in the meantime.

authors: IvanGoncharov frontendphil jbrown215 lydell


text:
[prelude] Add undefined

https://developer.mozilla.org/ru/docs/Web/JavaScript/Reference/Global_Objects/undefined lol

What exactly should be in no_flowlib lib?

source: gharchive/pull-request


text:
infer fails to download and install due to incorrect tar command arguments

The installation for linux (as described on http://fbinfer.com/docs/getting-started.html)
VERSION=0.XX.Y \
curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" \
| sudo tar -C /opt xf && \
ln -s "/opt/infer-linux64-v$VERSION/bin/infer" /usr/local/bin/infer

fails due to incorrect tar command arguments i.e tar -C /opt xf
tar: You must specify one of the '-Acdtrux', '--delete' or '--test-label' options
Try 'tar --help' or 'tar --usage' for more information.

Actually, it should be
VERSION=0.XX.Y \
curl -sSL "https://github.com/facebook/infer/releases/download/v$VERSION/infer-linux64-v$VERSION.tar.xz" \
| sudo tar -C /opt -xJ && \
ln -s "/opt/infer-linux64-v$VERSION/bin/infer" /usr/local/bin/infer

repo: facebook/infer


text:
Enabling reference images specific to a device

I think it can be useful to have reference images specific to a certain device.
For example tests with reference image created by the iPhone 5 simulator sometimes fail on iPhone 6 since it has more real estate to fit text.
For CI it is a good idea to test all different phone sizes, namely iPhone 4s, iPhone 5, iPhone 6, iPhone 6 Plus. However, currently the only differentiation FBSnapshotTestCase makes is between scale factors.
P.S. I've tried to follow the code style used for the usesDrawViewHierarchyInRect property. However, it might be better if all code for extracting the device/simulator name is extracted in a class.
Also, it might be helpful to be able to set the deviceSpecificCase property globally for all test suites (via a static member or environmental variable).
If you agree, I'd be happy to modify the pull request.

@nsobadzhiev Please take a look at deviceAgnostic property. I think this is pretty same feature.

@Grubas7 Sure, sorry. Should have pulled the latest changes before adding the feature.

repo: facebook/ios-snapshot-test-case


text:
Provide changelog

There was recently a minor uptick 0.1.x to 0.2.x, but it is difficult to tell what the change was without a changelog. Thanks! ...now at 0.4.0 :P

+1

+1 we're up to v0.4.0 and still don't know if the features I need are there.

0.4.1 just got released. what changed?

0.4.1 "Add --noHighlight option"

Thank you for reporting this issue and appreciate your patience. We've  notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.

Yes we will do this from now on. Thank you for bringing it to our attention :)

authors: YPCrumble browniefed cpojer crccheck facebook-github-bot-3 landau rayshan

repo: facebook/jest


text:
spyOn not working as expected

Hi, perhaps I'm not understanding how Jest's spyOn works, but I'm testing my Action Creators and I'm spying on two methods that should both be called when the correct condition is met, but only one method seems to be getting called and I'm not sure if I'm doing something wrong or if there's a bug in Jest's spyOn implementation.
The method I'm testing:
export const redirectToRootTestClass = (orgId, projectId, testClassList) => {
    const rootTestClassId = ProjectHelper.getBaseTemplateId(testClassList);
    const redirectPath = ProjectHelper.getTestClassRedirectPath(orgId, projectId, rootTestClassId);

    return function(dispatch) {
        dispatch({
            type: ProjectTestClassActions.REDIRECTING_TO_ROOT_TEST_CLASS
        });

        dispatch(replace(redirectPath));

        if (rootTestClassId) { // <-- this results in a value of 123
            dispatch(fetchProjectTestClass(orgId, projectId, rootTestClassId)); // spying on this method
            dispatch(fetchTestClassMethodList(orgId, projectId, rootTestClassId)); // spying on this method
        }
    };
};

The test:
import * as actions from 'app/projects/test-classes/ProjectTestClassActions';
import * as testMethodActions from 'app/projects/test-classes/test-method/ProjectTestMethodActions';

it('should fetch the list of test classes and methods if the getBaseTemplateId() method returns a value', (done) => {
    const spyOne = jest.spyOn(actions, 'fetchProjectTestClass');
    const spyTwo = jest.spyOn(testMethodActions, 'fetchTestClassMethodList');
    const classes = [{
        id: 123,
        name: 'TestClassTemplate',
        isRoot: true
    }];
    const store = mockStore({});

    store.dispatch(actions.redirectToRootTestClass(1, 2, classes));

    setTimeout(() => {
        expect(spyOne).toHaveBeenCalled(); // does not get called
        expect(spyTwo).toHaveBeenCalled(); // does get called
        done();
    }, 100);
});

The result:
spyOne.mock =  { calls: [], instances: [], timestamps: [] }
spyTwo.mock =  { calls: [ [ 1, 2, 123 ] ], instances: [ undefined ], timestamps: [ 1515523950597 ] }

SpyOne and SpyTwo should both be getting called with the same inputs, but only the second one is getting called for some reason. Would love some insight as to why this is happening.
Using Jest version 22.0.4

I think this should be
import MyClass from '../src/MyClass';

describe('MyClass', () => {
    it('should call the SOME_EVENT listener', () => {
        const spy = jest.spyOn(MyClass.prototype, '_onSomeEvent');
        const instance = new MyClass();
        instance._emitter.emit('SOME_EVENT');
        expect(spy).toHaveBeenCalled();
    });
});

Hey all, going to close as I don't think there's anything here demonstrating a bug
If you need help using spyOn, we recommend using our discord channel or StackOverflow where there is an active jestjs tag for questions

Thanks @ramiel
Only issue I see with that is if you have some code that creates multiple instances, but you only want to spy on the listener of one of those instances.
Simple example:
it('should call the SOME_EVENT listener', () => {
    const spy = jest.spyOn(MyClass.prototype, '_onSomeEvent');
    const instance = new MyClass();
    instance._emitter.emit('SOME_EVENT');

    const otherInstance = new MyClass();
    otherInstance._emitter.emit('SOME_EVENT');

    expect(spy.mock.calls.length).toEqual(1);
});

The test fails as the spy gets called twice.

The test fails because its specification is wrong. If you call emit two times you should expect to have it called two times. By the way I understand your problem, you want to know it per instance. In the code you just wrote you can write
it('should call the SOME_EVENT listener', () => {

    const instance = new MyClass();
    instance._emitter.emit('SOME_EVENT');

    const otherInstance = new MyClass();
    const spy = jest.spyOn(otherInstance._emitter, 'emit');
    otherInstance._emitter.emit('SOME_EVENT');

    expect(spy.mock.calls.length).toEqual(1);
});

but in your original code you called emit in the constructor which make this test impossible to write like that

authors: d-scott goodbomb ramiel rickhanlonii


text:
Add missing dependency

The jest-config package depends on jest-matcher-utils, which isn't listed into its dependencies. It breaks the installation when running a package manager with no hoisting mechanism :)

Thanks! I'm going to merge this but at the same time, jest-config shouldn't import getType from matcher-utils. cc @thymikee.

authors: arcanis cpojer


text:
Add the Yammer logo to the 'who is using this' section of the website.

Summary
This change adds Yammer to the list of companies that are using Jest on the website.
Test plan

Codecov Report

Merging #4971 into master will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##           master    #4971   +/-   ##
=======================================
  Coverage   60.21%   60.21%
=======================================
  Files         198      198
  Lines        6620     6620
  Branches        3        4    +1
=======================================
  Hits         3986     3986
  Misses       2634     2634

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d2eb37...fd31fab. Read the comment docs.

Thanks for using Jest!

Hi @cpojer.  Sorry for the noise, but can we revert this for the time being? We need to do some internal discussions and potentially submit this in a different form later.

Can you send a pull request for the revert?

From: Ben Lakey notifications@github.com
Sent: Thursday, November 30, 2017 4:28:55 AM
To: facebook/jest
Cc: Christoph Nakazawa; Mention
Subject: Re: [facebook/jest] Add the Yammer logo to the 'who is using this' section of the website. (#4971)
Hi @cpojerhttps://github.com/cpojer. Sorry for the noise, but can we revert this for the time being? We need to do some internal discussions and potentially submit this in a different form later.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHubhttps://github.com/facebook/jest/pull/4971#issuecomment-348079489, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AAA0KFjCWBe8-XHqntbw7MeoyAoPzJiNks5s7i8HgaJpZM4QsJlT.

Sure here it is: https://github.com/facebook/jest/pull/4987

authors: benlakey codecov-io cpojer


text:
Feature: Scroll for table

Description
It would be great if the table had its own scroll bar. Right now, the scroll affects the entire document, which is not very convenient.
The video shows an example of how this is implemented in other projects.
https://github.com/user-attachments/assets/00519b81-a211-4d6f-bfe8-824a99980b9a

I tried to solve this problem, but the createDOM method of ElementNode does not support nested elements

Can ElementNode add a method createDOMContainer to create a DOM container that wraps the DOM ? @zurfyx

Hey, It would be great to have this feature. +1

+1

+1

As quick workaround (before we will have nested elements support) you can use css:
table {
  width: 100%;
  overflow: auto;
  display: block;
}

And keep in mind that whole editor container must have width

+++++++

Fell into the same issue, please help!

I am trying to solve it by customElements,  but were some issues. pr: #6587

Thanks to @yaojiu19 for offering to contribute to this issue, although that PR doesn't solve the problem in "the lexical way" as the maintainers mentioned there.
I'm willing to solve this issue myself, but first I'd like to know if the Lexical team thinks it's ok to introduce a new ElementNode that acts as a wrapper.

@GermanJablo The biggest problems with #6587 are that there are exactly zero lines of tests, documentation or examples. There's no way to know whether it works at all other than to fill in all the missing pieces. Does it say it solves a problem? Sure. Does it actually? Does it break anything for people who are using custom nodes with however Lexical interacts with them today? Who knows. Can't possibly approve it in its current state.
Custom elements aren't used or tested anywhere else in Lexical, and that it's unclear there wouldn't be other problems with this approach (regarding selection, events, or anything else). A different approach that did not add custom elements was in #5930 / #5981 but that also stalled in part because you questioned what utility it would have, so it too is missing all of the finishing work that would have to be done before anyone knows if it is a real solution or not.

I don’t see why I would be responsible for PR 5930 being stalled. If that's the case for some reason, I encourage anyone who wants to continue it :)
As far as this issue is concerned, what I am suggesting is adding a new ElementNode, which seems to me to be the simplest solution.

I'm sure the large part that it's just a hard problem to solve, but your feedback on that PR was the only negative feedback and may have contributed to them losing steam. Adding a new kind of ElementNode that has components that are otherwise "invisible" to the reconciler is more or less equivalent to having a DecoratorElementNode, so going back to that PR and looking more closely might be worth your time. Note that any decorator can render all of its children directly in createDOM/updateDOM and return null from its decorate method if there isn't a need for a framework managed portal. I look forward to seeing what you come up with!

I have opened a PR that closes this issue: https://github.com/facebook/lexical/pull/6713.
Comments and observations are welcome.

Hi @GermanJablo, great job, I love this feature.
Do you believe it's possible to have a table inside the document that its width is larger than the document and the table can be shown like in Quip:

As you can see, the table width is larger than the document content, but still the table is shown without the horizontal scroll.
Perhaps with your implementation it's possible to achieve this result as well.

Thanks @agscripter. Yes, that should be possible by playing with the paddings

now I implement it through plugins

create a scrollbar outside the editor by watch the width and root element of the table

authors: CojocaruCristi GermanJablo MaslovRustislav agscripter alphaCastor bilobom denindka etrepum keiseiTi lxzmo yaojiu19

repo: facebook/lexical


text:
Check for specific excluded props

excludedProperties is a global list of properties that are not synced in collab mode, which includes node-specific props like __size, __first, __last (that should be filtered for elements only), or __text which is relevant for text nodes. That introduces possible issue where a decorator node (let's say Emoji) can have perfectly valid __size property, but it won't be sync'd over collab because it's filtered out for all nodes.
This PR checks if property should be excluded based on node type (element, text, root) and any extra excluded props from plugin to avoid it
Ref #3670

https://github.com/facebook/lexical/pull/4275

#4275

That one is still in place, it's just core properties are filtered out more precisely (e.g., __size only filtered from element nodes, but not text/decorators)

authors: acywatson fantactuka


text:
Use where instead of which on windows to properly detect watchman

The FileWatcher didn't detect watchman properly on windows since it relied on the which command. The windows equivalent is where. It didn't cause any real issue since it falls back on the NodeWatcher but it keeps printing an annoying error in the console.
Test plan
Tested on windows that it properly uses watchman if present using the windows built in where command.

We can also call watchman version instead, I think @amasad wanted to do that too.

Is that good? execSync will throw when watchman is not installed and {stdio: 'ignore'} to not redirect stderr to the console.

I don't know! @davidaurelio @amasad do you know!?

LGTM

authors: amasad cpojer janicduplessis

repo: facebook/node-haste


text:
docs: Remove advice to enable Fast Refresh for new apps

RN 0.61 enables Fast Refresh by default for new apps. There is no need to instruct users to manually enable it in the Getting Started guide.

Good point! Since this change is only to the /docs directory, it won't change the 0.61 docs located in website/versioned_docs/0.61, it will only change the next version of the docs.
Feel free to follow up with another PR changing them there!

Thanks for the info and quick merge! Looks like @Naturalclar has taken care of updating the 0.61 docs in #1538.

authors: pdsouza rickhanlonii

repo: facebook/react-native-website


text:
TypeError: Cannot read property 'replace' of undefined at Module.extractRequires [as _extractor]

Description
I recently upgraded my react-native package and some others in my package.json to the latest release. Each time I try to compile me project, I run into a this error in the terminal:
TypeError: Cannot read property 'replace' of undefined
    at Module.extractRequires [as _extractor] (PATH_TO_PROJECT/node_modules/react-native/packager/react-packager/src/node-haste/lib/extractRequires.js:31:10)
    at codePromise.then.result (PATH_TO_PROJECT/node_modules/react-native/packager/react-packager/src/node-haste/Module.js:209:49)
    at tryCallOne (PATH_TO_PROJECT/node_modules/promise/lib/core.js:37:12)
    at PATH_TO_PROJECT/node_modules/promise/lib/core.js:123:15
    at flush (PATH_TO_PROJECT/node_modules/asap/raw.js:50:29)
    at _combinedTickCallback (internal/process/next_tick.js:67:7)
    at process._tickCallback (internal/process/next_tick.js:98:9)

The simulator throws the following error:
{"type":"InternalError","message":"react-packager has encountered an internal error, please check your terminal error output for more details"}

I can't tell if this is a source code problem, or if I messed up somehow in updating my npm packages.
Additional Information

React Native version: 0.39.2
Platform: iOS
Operating System: MacOS

How did you upgrade? I suggest using http://facebook.github.io/react-native/blog/2016/12/05/easier-upgrades.html to do upgrades.

I managed to sort this out. Thanks for the link though.

@crellison How did you sort this out?

@shkfnly I wish I could tell you. I was updating my RN package and some other RN npm modules at the same time and lost track of what was new and what was old. I ended up updating everything to the latest release regardless and looked at recently posted issues on each page. This one may have been due to a mismatch of ReactNative and React, but I'm really not sure at this point. I wish I could help more...

@shkfnly @crellison has any of you some extra information on this? I've also updated all my dependencies to the latest version and I'm running into the same issue...

A clean restart of the packager solved the issue for me.
watchman watch-del-all
rm -rf node_modules && yarn
npm start -- --reset-cache

authors: JeroenNelen crellison hyb175 lacker shkfnly

repo: facebook/react-native


text:
Vertical and Horizontal Indent incorrectly work

If use padding/margin+Vertical/Horizontal after margin/padding+Left/Right/Bottom/Top, styles not overwritten! Why? If use this an approach in the web we see correct behavior overwritten.
http://take.ms/Li3dd

Closing this issue because it has been inactive for a while. If you think it should still be opened let us know why.

authors: MrChe hramos


text:
i'm using Linking.openURL(url). But url being open in safiri. i want to link open in my app. Anyone can help me.

Please read the following carefully before opening a new issue.
Your issue may be closed if it does not provide the information required by this template.
We use GitHub Issues for tracking bugs in React Native.

If you have a question, ask on Stack Overflow: http://stackoverflow.com/questions/tagged/react-native
If you have a feature request, post it on Canny: https://react-native.canny.io/feature-requests

--- Delete everything above this line ---
Description
Explain what you did, what you expected to happen, and what actually happens.
Reproduction Steps and Sample Code
Try to reproduce your bug on https://sketch.expo.io/ and provide a link.
If you can't reproduce the bug on Sketch, provide a sample project. At the very least, provide an example of your code.
Solution
What needs to be done to address this issue? Ideally, provide a pull request with a fix.
Additional Information

React Native version: [FILL THIS OUT: Be specific, filling out "latest" here is not enough.]
Platform: [FILL THIS OUT: iOS, Android, or both?]
Development Operating System: [FILL THIS OUT: Are you developing on MacOS, Linux, or Windows?]
Dev tools: [FILL THIS OUT: Xcode or Android Studio version, iOS or Android SDK version, if applicable]

@trung1008 You should use a WebView instead of Linking.
https://facebook.github.io/react-native/docs/webview.html


text:
React Native image borderRadius not working.

Image borderRadius/Native base Thumbnail circular shape/Gifted chat showUserAvatar={true}/any type of circular images are not working in Android 5.1 Lollipop.
Details
I am trying to display an image from a URL. In the emulator image displays perfectly. When I run this on the device it displays a black block and after some moment the app crashes without any error. (I have reveiw the adb logcat)
If I remove borderRadius property from Image style it works perfectly. But I need the circular shape.
I tried to native-base Thumbnail instead of Image but the problem persists. Then I tried to make a circular shape using View with overflow:hidden property but image edge not smooth. How can I solve this?
Screenshots
Black Block image in the device

Example of code

Please pardon any mistake and help me.

react-native info command not work.
_

C:\Users\Name\MyProject>react-native info
info Fetching system and libraries information...
error Unable to print environment info.
Error: Command failed: wmic os get Caption
'wmic' is not recognized as an internal or external command,
operable program or batch file.

_
react-native -v command:
react-native-cli: 2.0.1
react-native: 0.61.5

Try to wrap the image with a view with the dimensions you want and, in the image, put these styles to resize, like this:
return (
        <View
            style={styles.container}
        >
            <Image
                style={styles.image}
                source={{ uri: <LINK OF IMAGE> }}
            />
        </View>
    )
}

const styles = StyleSheet.create({
    container: {
        height: 150,
        width: Dimensions.get('window').width / 3,
        marginHorizontal: 5,
        justifyContent: 'center',
        alignItems: 'center',
    },
    image: {
        flex: 1,
        width: null,
        height: null,
        resizeMode: 'contain'
    },
})

If it doesn't work, try replacing the image style with:
image: {           width: '100%',         resizeMode: 'contain',         borderRadius: 60  }

I have try this. Image not display both emulator and device.

The problem is solved.
The main problem was Google Cloud Storage where I stored the pictures.
Having trouble using various features of Google Cloud Platform from my country.
The black blocks we see here are basically loading from cache memory. So these are showing black block in circular shape. Because, images are saved in cache memory with square shape.
I have tried in VPN and everything is ok.
Thank you.

The problem is solved.
The main problem was Google Cloud Storage where I stored the pictures.
Having trouble using various features of Google Cloud Platform from my country.
The black blocks we see here are basically loading from cache memory. So these are showing black block in circular shape. Because, images are saved in cache memory with square shape.
I have tried in VPN and everything is ok.
Thank you.


text:
"react-native run-android " in the cmd meet with "cannot download the gradle" problem

info Fetching system and libraries information...
System:
OS: Windows 10 10.0.18362
CPU: (6) x64 Intel(R) Core(TM) i5-8400 CPU @ 2.80GHz
Memory: 5.00 GB / 15.86 GB
Binaries:
Node: 12.18.0 - D:\dev\rn\install\node.EXE
Yarn: 1.17.3 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.4 - D:\dev\rn\install\npm.CMD
Watchman: Not Found
SDKs:
Android SDK:
API Levels: 10, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28
Build Tools: 23.0.1, 23.0.2, 23.0.3, 24.0.0, 24.0.2, 25.0.0, 25.0.2, 26.0.2, 27.0.2, 27.0.3, 28.0.0, 28.0.1, 28.0.2, 28.0.3
System Images: android-25 | Google APIs Intel x86 Atom, android-28 | Intel x86 Atom, android-28 | Intel x86 Atom_64, android-28 | Google APIs Intel x86 Atom, android-28 | Google Play Intel x86 Atom
Android NDK: 19.0.5232133
IDEs:
Android Studio: Not Found
Languages:
Java: Not Found
Python: 3.6.3
npmPackages:
@react-native-community/cli: Not Found
react: 16.11.0 => 16.11.0
react-native: 0.62.2 => 0.62.2
npmGlobalPackages:
react-native: Not Found

Your stacktrace says you are behind a proxy
Your info says you don't have Java JDK installed

Hi @zhangyang520 you can run npx react-native doctor on the root of your RN project to check for environment issues.
For future, environment issues Stack Overflow would be the more appropriate place to ask this. Thanks!

authors: jupmorenor safaiyeh zhangyang520


text:
Build failed - upgraded Xcode to 14.3

Description
When trying to run an app for iOS on Apple Silicon Mac and Xcode upgraded to 14.3 opening, build process failed.
So, I am temporarily modifying the node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp file directly to run the application.
The modification is within the
node->setLayoutHadOverflow(
node->getLayout().hadOverflow() |
currentRelativeChild->getLayout().hadOverflow());

code, where using the OR operator to represent a boolean seems incorrect.
Therefore, I searched throughout the file and replaced all instances of "|" with "||" for boolean.
When I checked the ReactCommon/yoga/yoga/Yoga.cpp file within the react-native(0.71.7) packages, I found that there is a problem with the OR operator within the setLayoutHadOverflow() function in one section.

I checked release 0.68.7. c3ad8 included bool problem.

React Native Version
0.66.4
Output of npx react-native info
System:
    OS: macOS 13.3.1
    CPU: (10) arm64 Apple M1 Pro
    Memory: 201.22 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 16.18.1 - ~/.nvm/versions/node/v16.18.1/bin/node
    Yarn: 1.22.19 - ~/.nvm/versions/node/v16.18.1/bin/yarn
    npm: 7.24.2 - ~/treasurer/node_modules/.bin/npm
    Watchman: 2023.04.17.00 - /opt/homebrew/bin/watchman
  Managers:
    CocoaPods: 1.11.3 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.4, iOS 16.4, macOS 13.3, tvOS 16.4, watchOS 9.4
    Android SDK: Not Found
  IDEs:
    Android Studio: 2022.2 AI-222.4459.24.2221.9862592
    Xcode: 14.3/14E222b - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.19 - /opt/homebrew/opt/openjdk@11/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: ^18.2.0 => 18.2.0
    react-native: 0.66.4 => 0.66.4
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

deleted all node_modules and Pods, Podfile.lock
yarn install && pod install
npx react-native run-ios

Snack, code example, screenshot, or link to a repository
023-05-02 20:38:58.848 xcodebuild[1724:2573445] DVTCoreDeviceEnabledState: DVTCoreDeviceEnabledState_Disabled set via user default (DVTEnableCoreDevice=disabled)
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:E3FB5CF8-5AA7-4236-9367-723C0D0A780E, OS:15.4, name:iPhone 13 }
{ platform:iOS Simulator, id:E3FB5CF8-5AA7-4236-9367-723C0D0A780E, OS:15.4, name:iPhone 13 }
** BUILD FAILED **

The following build commands failed:
        CompileC /Users/woals4815/Library/Developer/Xcode/DerivedData/Treasurer-expaulejrsifxsbnepqmmrqpfvew/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/Yoga.build/Objects-normal/arm64/Yoga.o /Users/woals4815/test-project/packages/app/node_modules/react-native/ReactCommon/yoga/yoga/Yoga.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'Yoga' from project 'Pods')
(1 failure)

Same problem here

0.66.4

You're on a old version of RN that most likely won't work with XCode 14. Please update to a later version and report back

@cortinico
Thanks for comment! 0.7.17 version of RN does work normally in XCode 14.
But i think this part should be fixed.
node->setLayoutHadOverflow(
node->getLayout().hadOverflow() |
currentRelativeChild->getLayout().hadOverflow());

Thanks for comment! 0.7.17 version of RN does work normally in XCode 14.

Closing because of this.

But i think this part should be fixed.

I'm unsure what are you asking us to fix @woals4815 can you clarify?

I have the same error when running the RN project.
M1 silicon
macOS 13.4
Xcode 14.3.1
RN 0.66.5
I am wondering that only M1 should update to the later RN version to avoid this issue ?
Cuz none of my colleagues who are using Intel silicon face this error while all of us are on the same version of macOS, Xcode and RN....

0.66.4

You're on a old version of RN that most likely won't work with XCode 14. Please update to a later version and report back

I've got the same issue

use xcode 14.1 is work
https://download.developer.apple.com/Developer_Tools/Xcode_14.1/Xcode_14.1.xip

@cortinico Thanks for comment! 0.7.17 version of RN does work normally in XCode 14. But i think this part should be fixed.
node->setLayoutHadOverflow(
node->getLayout().hadOverflow() |
currentRelativeChild->getLayout().hadOverflow());

after adding this line i get the following build commands failed: CompileC /Users/myname/projects/projectname/ios/DerivedData/aido/Build/Intermediates.noindex/Pods.build/Debug-iphonesimulator/RCT-Folly.build/Objects-normal/arm64/json.o /Users/myname/projects/projectname/ios/Pods/RCT-Folly/folly/json.cpp normal arm64 c++ com.apple.compilers.llvm.clang.1_0.compiler (in target 'RCT-Folly' from project 'Pods') (1 failure)

authors: cortinico fusandy guttymora sufyansalim sylvainp woals4815 yoonzm


text:
Allow ScrollView to be forced to become responder

There is a bug when a ScrollView is inside a PanResponder making it unable scroll (see #11206 and #6764)
I tried diving into the ScrollResponder mixin and the ResponderEventPlugin, but could not find a solution without the guarantee of breaking anything.
This tiny patch adds a flag prop (forceSetResponder) to force the ScrollView to become the responder when it is touched. It does not change the behavior in any way when not activated, making it safe.

I just signed the CLA (after the warning)

@brendan-rius can you fix lint issues?

@matpaul i just fixed them :)

authors: brendan-rius matpaul


text:
fix typo - closes #13369

Motivation
We're just fixing a reported typo from the docs.
Test Plan
proofreading

It's a typo fix. I assume build error is unrelated


text:
Update documentation to use newer version of fresco - fixes #13345

Thanks for submitting a PR! Please read these instructions carefully:
Motivation (required)
React Native crashes hard on fresco 0.11.0 - see #13345
Test Plan (required)
Repro case in #13345

As of 0.43.0 react native uses Fresco 1.0.1, could you change to that version?
https://github.com/facebook/react-native/blob/0.43-stable/ReactAndroid/build.gradle#L280

@AndrewJack confirmed. it works. I updated the PR
BUT: I think this will probably break again with future RN update ;-(

@forki It probably will. Ideally the release notes would detail it as a breaking change.
Always worth checking the versions that react native uses when upgrading.

there is no way to bundle it automatically with the correct version? or make the upgrade tool fix it at least?

Upgrade tool won't work in this case because the fresco addons are optional.
The extra fresco dependencies weren't included in the react native library to reduce the app size for people who don't need the extra fresco features.

Upgrade tool could be smart and to string replacement. But I assume release
notes will be good enough.
Am 10.04.2017 16:30 schrieb "Andrew Jack" notifications@github.com:

Upgrade tool won't work in this case because the fresco addons are
optional.
The extra fresco dependencies weren't included in the react native library
to reduce the app size for people who don't need the extra fresco features.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/facebook/react-native/pull/13419#issuecomment-292966583,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AADgNIq7-Rt1f6Kt3gfWWU7yXHsKgvRAks5ruj0PgaJpZM4M4xu3
.

authors: AndrewJack forki


text:
[podspec] Define pod_target_xcconfig for PrivateDatabase

We don't strictly need this since all the other subspecs that use this set up the header search path for ReactCommon anyway but do it just for correctness.
Test Plan: install iOS pods
Release Notes
[podspec] Define pod_target_xcconfig for PrivateDatabase

👍 @facebook-github-bot shipit

👍
@facebook-github-bot shipit

authors: ide janicduplessis


text:
Question: Top level ReactDOM.render() into body rather than a 'root' element

Is there a particular reason why the initial create-react-app index.html file and index.js file construct it so that the application root is rendered into a #root element rather than the body directly?
I can understand keeping the React application at a lower level for applications which run multiple view layers within the same document, but for an app delivered solely by React the #root element seems like a redundant DOM node.
Chris

If you render directly into document.body, you risk collisions with scripts that do something with it (e.g. Google Font Loader or third party browser extensions) which produce very weird and hard to debug errors in production. React warns you if you attempt to do this.

authors: cjpete gaearon

repo: facebookincubator/create-react-app


text:
Cannot find name 'bigint'

Type: Bug
Version: 2.5.4
Subject: Type Error
Environment: TypeScript 3.1.6
We are receiving the following error on build with the latest version (2.5.4).
ERROR in node_modules/idx/lib/idx.d.ts(52,21): error TS2304: Cannot find name 'bigint'.
node_modules/idx/lib/idx.d.ts(53,13): error TS2304: Cannot find name 'bigint'.

You need to upgrade to TypeScript 3.2

Hi @mohsen1
I got that already. I just wanted to make sure you are aware of the issue. After all, this is a breaking change for TypeScript users and the version number is increased just as if it is a patch. It will break compilations all over the world and people will have to take action.
If you want to fix this, you can publish a minor release (2.6.0) or, even better a major release (3.0.0), then revert the change and make another patch to the older version (2.5.5). Additionally, this should be documented well to avoid further misunderstandings.

With TypeScript and @types/ packages the stance is that your code will break with any change, including patch versions. idx is shipping it's own types so it's a bit different. That being said, the types here require some minimum version of TypeScript anyways. We're using conditional types that was introduced in TypeScript 3 for instance. We don't want to make TypeScript a peer dependency of idx either, you don't need to have TypeScript to use idx.
I'll leave it to package maintainers to decide. Removing 'bigint' will not break too many people vs. depending on at least TypeScript@3.2

I'm down to make the necessary changes for idx to be compatible with older versions of TypeScript, publish idx@2.5.5, and then revert those changes and publish idx@3.0.0.
Would either of you be down to make the minimal changes necessary for idx@2.5.5?

I just published idx@2.5.5 which includes https://github.com/facebookincubator/idx/pull/80. Thanks everyone!

Thanks @mohsen1 and @yungsters. It is most appreciated.

authors: armanozak mohsen1 yungsters

repo: facebookincubator/idx


text:
Missing initial salt for MVFST_EXPERIMENTAL

Hello,
As part of a pentesting project, I find myself decrypting quic packets with wireshark. For that, I need the initial salt for each version of the quic protocol used.
I recently found some packets with hexcode version FACEB00E, which, according to this repo, correspond to version MVFST_EXPERIMENTAL (line 246 in QuicConstants.h)
But this version is not mapped to any kQuicDraft**Salt in FizzCryptoFactory.cpp.
Is this version using the default salt, as per the switch in the file above? Can it be assumed this MVFST_EXPERIMENTAL will not be remapped to another salt in the future?
Thanks for the help

I think your reading of the code is correct, it will use salt in the default branch.

Can it be assumed this MVFST_EXPERIMENTAL will not be remapped to another salt in the future?

MVFST_EXPERIMENTAL as a version may not always exist. And kQuicDraft23Salt value may not always exist in the future either. So this can be changed in the future.

repo: facebookincubator/mvfst


text:
Right semi join returns incorrect result

Description
Run fuzzer join test with the following parameters: --logtostderr --duration_sec 120 --batch_size=5 --seed 2199528297
I20230103 13:56:15.395974 6804843 JoinFuzzer.cpp:693] ==============================> Started iteration 166 (seed: 3935760440)
...
I20230103 13:56:15.422427 6804843 JoinFuzzer.cpp:271] Results: [ROW ROW<u2:SMALLINT,t0:INTEGER,tp3:ARRAY,t2:SMALLINT>: 28 elements, no nulls]
I20230103 13:56:15.422834 6804843 JoinFuzzer.cpp:660] Testing plan #4
I20230103 13:56:15.422843 6804843 JoinFuzzer.cpp:257] Executing query plan:
-- HashJoin[FULL t0=u0 AND t2=u2 AND t1=u1] -> u2:SMALLINT, t0:INTEGER, tp3:ARRAY, t2:SMALLINT
-- LocalPartition[REPARTITION] -> t0:INTEGER, t1:VARCHAR, t2:SMALLINT, tp3:ARRAY, tp4:MAP<BOOLEAN,INTEGER>
-- Values[10 rows in 2 vectors] -> t0:INTEGER, t1:VARCHAR, t2:SMALLINT, tp3:ARRAY, tp4:MAP<BOOLEAN,INTEGER>
-- Values[5 rows in 1 vectors] -> t0:INTEGER, t1:VARCHAR, t2:SMALLINT, tp3:ARRAY, tp4:MAP<BOOLEAN,INTEGER>
-- Values[5 rows in 1 vectors] -> t0:INTEGER, t1:VARCHAR, t2:SMALLINT, tp3:ARRAY, tp4:MAP<BOOLEAN,INTEGER>
-- Values[5 rows in 1 vectors] -> t0:INTEGER, t1:VARCHAR, t2:SMALLINT, tp3:ARRAY, tp4:MAP<BOOLEAN,INTEGER>
-- LocalPartition[REPARTITION] -> u0:INTEGER, u1:VARCHAR, u2:SMALLINT
-- Values[2 rows in 2 vectors] -> u0:INTEGER, u1:VARCHAR, u2:SMALLINT
-- Values[1 rows in 1 vectors] -> u0:INTEGER, u1:VARCHAR, u2:SMALLINT
-- Values[1 rows in 1 vectors] -> u0:INTEGER, u1:VARCHAR, u2:SMALLINT
-- Values[1 rows in 1 vectors] -> u0:INTEGER, u1:VARCHAR, u2:SMALLINT
W20230103 13:56:15.424777 6810413 VeloxPromise.h:40] PROMISE: Unfulfilled promise is being deleted. Context: Task::allPeersFinished test_cursor 1070
I20230103 13:56:15.425218 6804843 JoinFuzzer.cpp:271] Results: [ROW ROW<u2:SMALLINT,t0:INTEGER,tp3:ARRAY,t2:SMALLINT>: 28 elements, no nulls]
I20230103 13:56:15.425736 6804843 JoinFuzzer.cpp:701] ==============================> Done with iteration 166
I20230103 13:56:15.425753 6804843 JoinFuzzer.cpp:693] ==============================> Started iteration 167 (seed: 897056553)
I20230103 13:56:15.426928 6804843 JoinFuzzer.cpp:257] Executing query plan:
-- HashJoin[LEFT SEMI (PROJECT) t4=u4 AND t0=u0 AND t1=u1 AND t3=u3 AND t2=u2] -> t0:BIGINT, t2:INTEGER, t1:VARBINARY, t3:INTEGER, tp5:ROWf0:INTEGER,f1:REAL, match:BOOLEAN
-- Values[25 rows in 5 vectors] -> t0:BIGINT, t1:VARBINARY, t2:INTEGER, t3:INTEGER, t4:VARCHAR, tp5:ROWf0:INTEGER,f1:REAL
-- Values[5 rows in 5 vectors] -> u0:BIGINT, u1:VARBINARY, u2:INTEGER, u3:INTEGER, u4:VARCHAR, bp5:ARRAY, bp6:ROWf0:REAL, bp7:ROWf0:REAL,f1:TIMESTAMP
I20230103 13:56:15.428032 6804843 JoinFuzzer.cpp:271] Results: [ROW ROW<t0:BIGINT,t2:INTEGER,t1:VARBINARY,t3:INTEGER,tp5:ROWf0:INTEGER,f1:REAL,match:BOOLEAN>: 25 elements, no nulls]
I20230103 13:56:15.428201 6804843 JoinFuzzer.cpp:660] Testing plan #0
I20230103 13:56:15.428210 6804843 JoinFuzzer.cpp:257] Executing query plan:
-- HashJoin[LEFT SEMI (PROJECT) t4=u4 AND t0=u0 AND t1=u1 AND t3=u3 AND t2=u2] -> t0:BIGINT, t2:INTEGER, t1:VARBINARY, t3:INTEGER, tp5:ROWf0:INTEGER,f1:REAL, match:BOOLEAN
-- Values[25 rows in 5 vectors] -> t0:BIGINT, t1:VARBINARY, t2:INTEGER, t3:INTEGER, t4:VARCHAR, tp5:ROWf0:INTEGER,f1:REAL
-- Values[5 rows in 5 vectors] -> u0:BIGINT, u1:VARBINARY, u2:INTEGER, u3:INTEGER, u4:VARCHAR, bp5:ARRAY, bp6:ROWf0:REAL, bp7:ROWf0:REAL,f1:TIMESTAMP
I20230103 13:56:15.429280 6804843 JoinFuzzer.cpp:271] Results: [ROW ROW<t0:BIGINT,t2:INTEGER,t1:VARBINARY,t3:INTEGER,tp5:ROWf0:INTEGER,f1:REAL,match:BOOLEAN>: 25 elements, no nulls]
I20230103 13:56:15.429558 6804843 JoinFuzzer.cpp:660] Testing plan #1
I20230103 13:56:15.429566 6804843 JoinFuzzer.cpp:257] Executing query plan:
-- HashJoin[RIGHT SEMI (PROJECT) u4=t4 AND u0=t0 AND u1=t1 AND u3=t3 AND u2=t2] -> t0:BIGINT, t2:INTEGER, t1:VARBINARY, t3:INTEGER, tp5:ROWf0:INTEGER,f1:REAL, match:BOOLEAN
-- Values[5 rows in 5 vectors] -> u0:BIGINT, u1:VARBINARY, u2:INTEGER, u3:INTEGER, u4:VARCHAR, bp5:ARRAY, bp6:ROWf0:REAL, bp7:ROWf0:REAL,f1:TIMESTAMP
-- Values[25 rows in 5 vectors] -> t0:BIGINT, t1:VARBINARY, t2:INTEGER, t3:INTEGER, t4:VARCHAR, tp5:ROWf0:INTEGER,f1:REAL
I20230103 13:56:15.430617 6804843 JoinFuzzer.cpp:271] Results: [ROW ROW<t0:BIGINT,t2:INTEGER,t1:VARBINARY,t3:INTEGER,tp5:ROWf0:INTEGER,f1:REAL,match:BOOLEAN>: 25 elements, no nulls]
E20230103 13:56:15.431311 6804843 Exceptions.h:68] Line: /Users/xiaoxmeng/code/presto_cpp/velox/velox/exec/tests/JoinFuzzer.cpp:664, Function:verify, Expression: assertEqualResults({expected}, {actual}) Logically equivalent plans produced different results, Source: RUNTIME, ErrorCode: INVALID_STATE
libc++abi: terminating with uncaught exception of type facebook::velox::VeloxRuntimeError: Exception: VeloxRuntimeError
Error Source: RUNTIME
Error Code: INVALID_STATE
Reason: Logically equivalent plans produced different results
Retriable: False
Expression: assertEqualResults({expected}, {actual})
Function: verify
File: /Users/xiaoxmeng/code/presto_cpp/velox/velox/exec/tests/JoinFuzzer.cpp
Line: 664
Stack trace:
...
/Users/xiaoxmeng/code/presto_cpp/velox/velox/exec/tests/utils/QueryAssertions.cpp:992: Failure
Value of: false
Actual: false
Expected: true
Expected 25, got 25
25 extra rows, 25 missing rows
10 of extra rows:
null | 218092068 | "x/m-?10dS@i9r|:S|8Ob.*y2[;u@NR7Y{O<Yy|AA'08pDE5S2A!q" | null | null | null 	null | 333520695 | null | 379296071 | [null,0.6685807704925537] | null 	null | 1351162162 | null | 379296071 | [1570896782,null] | null 	null | 1430253304 | "N'ioyH#;UYZ~lvlD*_nrO|,09]Uh1WK2sykl$wXmXdC0eSQ]C\\>r~Z<[5s'z@2Ba7(j=&b+KP"Jsr&;yzYL!2h2Q1" | null | [875193945,0.7851024866104126] | null
253982179219790907 | 566640434 | null | null | [1540924563,0.2357754409313202] | null
1364886058125287610 | 2130063901 | "dA_$PR.d.x|(B=Yq|!Y7^Dn"|,$R\+%bXC-+1|wP2QY.C1tZwav\x'"ac)7)mRcm1NDY')U]2$x;e+=WJ0-]~~/MVi" | 2094742274 | [2142371382,0.6333921551704407] | null 	1699526393999299079 | null | null | 1143322133 | [773893561,0.801523745059967] | null 	1699526393999299079 | 1143936907 | "N'ioyH#;UYZ~lvlD*_nrO|,09]Uh1WK2sykl$wXmXdC0eSQ]C\\>r~Z<[5s'z@2Ba7(j=&b+KP"Jsr&;yzYL!2h2Q1" | 312860059 | [773893561,0.801523745059967] | null
1706895570413328037 | 566640434 | null | null | [null,0.7522648572921753] | null
3300686975662340930 | 664141492 | null | 379296071 | [null,null] | null
10 of missing rows:
null | 218092068 | "x/m-?10dS@i9r|:S|8Ob.*y2[;u@NR7Y{O<Yy|AA'08pDE5S2A!q" | null | null | false 	null | 333520695 | null | 379296071 | [null,0.6685807704925537] | false 	null | 1351162162 | null | 379296071 | [1570896782,null] | false 	null | 1430253304 | "N'ioyH#;UYZ~lvlD*_nrO|,09]Uh1WK2sykl$wXmXdC0eSQ]C\\>r~Z<[5s'z@2Ba7(j=&b+KP"Jsr&;yzYL!2h2Q1" | null | [875193945,0.7851024866104126] | false
253982179219790907 | 566640434 | null | null | [1540924563,0.2357754409313202] | false
1364886058125287610 | 2130063901 | "dA_$PR.d.x|(B=Yq|!Y7^Dn"|,$R\+%bXC-+1|wP2QY.C1tZwav\x'"ac)7)mRcm1NDY')U]2$x;e+=WJ0-]~~/MVi" | 2094742274 | [2142371382,0.6333921551704407] | false 	1699526393999299079 | null | null | 1143322133 | [773893561,0.801523745059967] | false 	1699526393999299079 | 1143936907 | "N'ioyH#;UYZ~lvlD*_nrO|,09]Uh1WK2sykl$wXmXdC0eSQ]C\\>r~Z<[5s'z@2Ba7(j=&b+KP"Jsr&;yzYL!2h2Q1" | 312860059 | [773893561,0.801523745059967] | false
1706895570413328037 | 566640434 | null | null | [null,0.7522648572921753] | false
3300686975662340930 | 664141492 | null | 379296071 | [null,null] | false
Unexpected results
Process finished with exit code 134 (interrupted by signal 6: SIGABRT)
Error Reproduction
Run fuzzer join test with the following parameters: --logtostderr --duration_sec 120 --batch_size=5 --seed 2199528297
Relevant logs
No response

cc @mbasmanova

Turns out that the bug is in left semi project join. When build side is not empty, but all rows have nulls in the join keys, the 'match' columns should be set to NULL, but it is currently set to FALSE.

authors: mbasmanova xiaoxmeng

repo: facebookincubator/velox


text:
Add serializeColumn to PrestoVectorSerde

Exposes serializeColumn via PrestoVectorSerde. Required to serialize column for
ConstantExpression::valueBlock in https://github.com/prestodb/presto/pull/22927 .

@pramodsatya : The changes look okay. But please can you explain what specifically in the linked PR needed these changes. I do recall our discussion. But it would be good for other reviewers as well.

@pramodsatya : The changes look okay. But please can you explain what specifically in the linked PR needed these changes. I do recall our discussion. But it would be good for other reviewers as well.

Thanks @aditi-pandit, updated the PR description to explain why this change is needed.

@kevinwilfong : What do you think of these changes ? Please can you help with this review.

Hi @pramodsatya, not sure if I'm following. Why can't you just serialize the results of the expression (which are probably encoded as constant vectors) as PrestoPage using this API? It will maintain the encoding, then they can be deserialized by the Presto Java code.

https://github.com/facebookincubator/velox/blob/main/velox/serializers/PrestoSerializer.h#L41-L43

Hi @pramodsatya, not sure if I'm following. Why can't you just serialize the results of the expression (which are probably encoded as constant vectors) as PrestoPage using this API? It will maintain the encoding, then they can be deserialized by the Presto Java code.

https://github.com/facebookincubator/velox/blob/main/velox/serializers/PrestoSerializer.h#L41-L43

Hi @pedroerp, thanks for the suggestion. Initially I did try to use the serialize function in PrestoBatchVectorSerializer, which serializes the velox vector in PrestoPage format, to serialize the constant encoded vector from exec::ConstantExpr into protocol::Block::data (for constructing the protocol::ConstantExpression::valueBlock). However, this was found to result in a deserialization error on the Presto coordinator. Upon further investigation, we noticed this was because the Presto coordinator expects just the serialized column from PrestoPage, without the header, in the field protocol::ConstantExpression::valueBlock::data.
We also noticed that in PrestoToVeloxExpr.cpp, the valueBlock from Presto protocol::ConstantExpression is converted to velox vector by deserializing just the column from PrestoPage (without the header) in function VeloxExprConverter::getConstantValue() -> deserializeSingleColumn (we are attempting to do an inverse operation to this function when constructing a Presto ConstantExpression from velox ConstantExpr here).
Using serializeColumn to construct valueBlock in protocol::ConstantExpression fixed the error (ref: function RowExpressionEvaluator::getConstantRowExpression in RowExpressionEvaluator.cpp) and we were able to test it end to end. We were also able to solve the serialization error by just skipping over the fixed number of bytes occupied by the header in PrestoPage, but since there already is a serializeColumn function present in the codebase, we figured it would be better to expose it for use via velox.
Please let me know if I am missing something.

@pramodsatya thank you for clarifying. Could we instead provide an option in PrestoOptions to make the serializer skip the header instead?
I think what I'm slightly concerned is moving VectorStream and all that stuff to the API (header) of this class, making the client more verbose, and the API a bit less intuitive.

authors: aditi-pandit pedroerp pramodsatya


text:
Support Parquet Benchmark for BigInt and Double with different Filter…

… and Null rates (#3211)
Summary:
This PR supports Parquet Benchmark for BigInt and Double with different Filter and Null rates on both Dictionary and Plain encoded Parquet files. Including:

Refactored the initial parquet benchmark so that it is able to support the benchmark on different types, filter rates, null rates and both Dictionary/Plain Parquet file encoding types.
Added the the element counter to the filter generator and increased the sample size to 65536 for more accurate filter rate estimation. Also, Added allowNulls to FilterSpec to generator non-null filters for the benchmark.

Pull Request resolved: https://github.com/facebookincubator/velox/pull/3211
Reviewed By: amitkdutta
Differential Revision: D41534760
Pulled By: Yuhta
fbshipit-source-id: e358cc8ee6f2ce414c06333f5223d584e99dca76

@yingsu00


text:
Make return type void during aggregate registration.

Summary: Aggregate function registration does not utilize return type. Some registrations are done with void and some are done with return type - where return type is unused. Making all of them void, similar to what is done in  https://github.com/facebookincubator/velox/pull/7689
Differential Revision: D51593723

Hi @amitkdutta, I think a previous PR intentionally make all aggregation registration functions return exec::AggregateRegistrationResult (#7133). Is there a reason why you'd like them to all return void instead?

@kagamiori The return type is unused - hence making it void. Also a suggestion in https://github.com/facebookincubator/velox/pull/7689#discussion_r1402170888


text:
the generated mp4 file not saved

Hi. Thank you for your excellent work. It seems does not create and save any mp4 file and gives the following error.

This issue has to do with the avc1 codec. It's possible your version of opencv doesn't have it due to licensing issues. This thread has some workarounds listed:
https://github.com/qqwweee/keras-yolo3/issues/269

authors: aartykov hjessmith

repo: facebookresearch/AnimatedDrawings


text:
Can we use backward within the forward function of a criterion?

❓ Questions and Help

What is your question?
Can we use a loss.backward() call within a criterion in fairseq? I am trying to write an adversarial version of the cross entropy loss.
Code (Forward Function)
   `sample2=copy.deepcopy(sample)
    sample2['net_input']['source']['video'].requires_grad=True
    net_output = model(**sample2["net_input"])
    loss_dummy, _ = self.compute_loss(model, net_output, sample2, reduce=reduce)
    sample2['net_input']['source']['video'].retain_grad()
    model.zero_grad()
    loss_dummy.backward()
    grad=sample2['net_input']['source']['video'].grad
    sign_data_grad = grad.sign()
    sample2['net_input']['source']['video']=sample2['net_input']['source']['video']+self.epsilon*sign_data_grad
    model.zero_grad()
    net_output_adv = model(finetune=False,**sample2["net_input"])
    loss_adv, nll_loss_adv = self.compute_loss(model, net_output_adv, sample2, reduce=reduce)
    net_output = model(finetune=False,**sample["net_input"])
    loss_clean, nll_loss = self.compute_loss(model, net_output, sample, reduce=reduce)
    sample_size = (
        sample["target"].size(0) if self.sentence_avg else sample["ntokens"]
    )
    loss=self.alpha*loss_clean+(1-self.alpha)*loss_adv`

What have you tried?
The line loss_dummy.backward() throws this error : Runtime error : Element 0 of tensor does not require grad and does not have a grad function. (During a fair-seq hydra script)
I tried  using the criterion in a python script, and it works perfectly fine, which made me assume it could be something to do with fairseq under the hood.
What's your environment?

fairseq Version (e.g., 1.0 or main): commit from https://github.com/facebookresearch/av_hubert
PyTorch Version (e.g., 1.0): 1.7
OS (e.g., Linux): Linux
How you installed fairseq (pip, source) : source
Build command you used (if compiling from source):(Instructions from https://github.com/facebookresearch/av_hubert)
Python version: 3.8
CUDA/cuDNN version:
GPU models and configuration:
Any other relevant information:

resolved

repo: facebookresearch/fairseq