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.

Add FLOW_RUNTIME=namespace configuration

See original GitHub issue

This is a:

  • Bug Report
  • Feature Request
  • Question
  • Other

Which concerns:

  • flow-runtime
  • babel-plugin-flow-runtime
  • flow-runtime-validators
  • flow-runtime-mobx
  • flow-config-parser
  • The documentation website

What is the current behaviour?

The current implementation of babel-plugin-flow-runtime allows configuration that either inlines the assertions or skips them at a compile them. This is good enough for developing a library that uses flow-runtime.

const add = (a: number, b: number): number => a + b;

is transformed to:

import t from 'flow-runtime';
const add = (a, b) => {
  let _aType = t.number();
  let _bType = t.number();
  const _returnType = t.return(t.number());
  t.param('a', _aType).assert(a);
  t.param('b', _bType).assert(b);
  return _returnType.assert(a + b);
};

However, it limits library author’s ability to distribute code with flow-runtime assertions. I do not want to use dependencies in production that have inlined flow-runtime assertions (for performance reasons).


What is the expected behaviour?

I’d like babel-plugin-flow-runtime to accept a configuration that inlines a conditional runtime assertion, e.g.

{
  "plugins": [["flow-runtime", {
    "assert": "applaudience:showtime-api"
  }]]
}

would produce code:

import t from 'flow-runtime';
const add = (a, b) => {
  if (process.env.FLOW_RUNTIME && process.env.FLOW_RUNTIME.startsWith('applaudience:showtime-api')) {
    let _aType = t.number();
    let _bType = t.number();
    const _returnType = t.return(t.number());
    t.param('a', _aType).assert(a);
    t.param('b', _bType).assert(b);
    return _returnType.assert(a + b);
  } else {
    return a + b;
  }
};

This is a mock implementation. A real-life implementation would follow the debug conventions.

This way, I could distribute all my codes with inlined flow-runtime assertions that users could enable when debugging issues the same way that debug is being used, e.g.

FLOW_RUNTIME=applaudience:* node ./index.js

would enable runtime type assertions for all dependencies under the “applaudience” namespace.


Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
phpnodecommented, Mar 5, 2017
0reactions
Amin-Medbellecommented, May 17, 2018

@phpnode Have you seen this article? It pretty much resolves the conditional plugin issues.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Specify the Runtime Configuration - SAP Help Portal
Open the integration flow and select the graphical area outside the integration flow model. Choose the Runtime Configuration tab.
Read more >
Set the Runtime Experience for URL-Based Flows
Are you distributing a flow via a URL? That includes things like direct URLs, custom buttons, and links in Setup. You can flip...
Read more >
Quick Start - Runtime Flow - Vlasov Studio
The Runtime Summary window lists all classes and functions that were used during a program run organized by modules and namespaces. All elements...
Read more >
Runtime - Task Configuration — Cylc 8.0b2 documentation
Any namespace can configure any or all of the items defined in flow.cylc . Namespaces that do not explicitly inherit from others ...
Read more >
Limits and configuration - Power Automate - Microsoft Learn
Actions per workflow, 500, You can add child flows to extend this ... on runtime behavior, use the trigger concurrency setting instead.
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