question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

addon-controls: Requests multiplying with each change

See original GitHub issue

Describe the bug When I edit a control value, the number of requests made to do so doubles from the previous attempt:

To Reproduce Steps to reproduce the behavior:

  1. Set up a Rails app with Webpack.
  2. Configure view_component_storybook for it by following their Getting Started guide. In addition, configure CORS headers according to my comment here, configure asset hosts, and change the root to spec/components/stories.
  3. Create a component using rails generate component Button button_text. Copy the stories they’ve written in the view_component_storybook README into spec/components/stories/button_component_stories.rb, and run rake view_component_storybook:write_stories_json.
  4. Install Storybook with npx -p @storybook/cli sb init -t html
  5. Override the configs with those I’ve left under Code snippets.
  6. Run rails s in one terminal instance and yarn storybook in another.
  7. The browser should open your Storybook instance.
  8. In either of the stories, change the Button Text control value by adding or removing a character.

Expected behavior

One request is made per change to an attribute.

Screenshots

Network traceback with twice the number of requests being sent with each change.

Code snippets

.storybook/main.js

module.exports = {
  stories: ["../spec/components/**/*.stories.json"],
  addons: [
    "@storybook/addon-controls",
    "@storybook/addon-links",
    "@storybook/addon-essentials",
  ],
}

.storybook/preview.js

export const parameters = {
  actions: { argTypesRegex: "^on[A-Z].*" },
  controls: {
    matchers: {
      color: /(background|color)$/i,
      date: /Date$/,
    },
  },
  server: {
    url: `http://localhost:3000/rails/stories`,
  },
}

Generated JSON

{
  "title": "Button Component",
  "stories": [
    {
      "name": "with_short_text",
      "parameters": {
        "server": {
          "id": "button_component/with_short_text"
        }
      },
      "args": {
        "button_text": "OK"
      },
      "argTypes": {
        "button_text": {
          "control": {
            "type": "text"
          },
          "name": "Button Text"
        }
      }
    },
    {
      "name": "with_long_text",
      "parameters": {
        "server": {
          "id": "button_component/with_long_text"
        }
      },
      "args": {
        "button_text": "Push Me Please!"
      },
      "argTypes": {
        "button_text": {
          "control": {
            "type": "text"
          },
          "name": "Button Text"
        }
      }
    }
  ]
}

System

Environment Info:

  System:
    OS: Linux 5.9 Manjaro Linux
    CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
  Binaries:
    Node: 14.15.5 - ~/.asdf/installs/nodejs/14.15.5/bin/node
    Yarn: 1.22.5 - ~/.asdf/installs/nodejs/14.15.5/.npm/bin/yarn
    npm: 6.14.11 - ~/.asdf/installs/nodejs/14.15.5/bin/npm
  Browsers:
    Firefox: 87.0
  npmPackages:
    @storybook/addon-actions: ^6.2.1 => 6.2.1 
    @storybook/addon-controls: ^6.2.1 => 6.2.1 
    @storybook/addon-essentials: ^6.2.1 => 6.2.1 
    @storybook/addon-links: ^6.2.1 => 6.2.1 
    @storybook/html: ^6.2.1 => 6.2.1 
    @storybook/server: ^6.2.1 => 6.2.1 

Additional context I imagine it’s probably possible to replicate even without the ViewComponent setup.

The first half of the requests that are sent have this traceback: image

The second half of the requests call _renderMain from render.js:95 before the first call to renderMain in the above traceback.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
boardfishcommented, Apr 1, 2021

I’ve just pulled together a reduced test case and the bug isn’t present. It’s not exactly identical at the time of writing because I haven’t configured some dependencies like Hotwire and Tailwind, but I’ll see if introducing those provokes the bug.

0reactions
boardfishcommented, Apr 1, 2021

Okay - I found this in the docs, which fits my use case perfectly. However,

const path = require("path")

const custom = require("../config/webpack/environment.js").toWebpackConfig()

module.exports = {
  webpackFinal: (config) => {
    return { ...config, module: { ...config.module, rules: custom.module.rules } }
  },
  stories: ["../spec/components/**/*.stories.json"],
  addons: ["@storybook/addon-controls"],
}

Whether I prefix the function with async or not, Storybook claims not to be able to find any stories. They’re definitely there, and if I start Storybook without webpackFinal in the exports, the stories show just fine.

ls ../spec/components/**/*.stories.json                                                                                                                                                              
../spec/components/stories/button_component.stories.json
Read more comments on GitHub >

github_iconTop Results From Across the Web

storybook/addon-controls - npm
Storybook Controls gives you a graphical UI to interact with a component's arguments dynamically, without needing to code. It creates an addon ...
Read more >
https://downloads.regulations.gov/EPA-HQ-OAR-2003-...
This new HAP emissions factor significantly changes the numerical value of the floor ( pounds of HAP emissions per ton of resin used)...
Read more >
storybookjs/storybook (Raised $170.00) - Issuehunt
addon-controls : Requests multiplying with each change. Unfunded#14436created byboardfish. $0.00. Environment variables in HTML files not working anymore.
Read more >
AES WR Partnership LOCATION: 11600
November 17, 2005. On July 28, 2005, AES requested administrative changes to two aspects of the PSD Approval and Permit to Construct Nos....
Read more >
Natural Gas Pipeline Company of America LLC - Station 307
Change oil and filter every 1,440 hours of operation or annually, ... The filing of a request by the permittee for a permit...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found