Skip to content

Conversation

brenthosie
Copy link
Member

@brenthosie brenthosie commented Oct 2, 2025

Description

Turbine will overwhelm the console when a user's implementation (either directly or indirectly through an extension they installed) accesses deprecated features. This changes aims to:

  1. audit the project's dependencies
  2. remove security vulnerabilities
  3. log deprecation to the console 1 time when outputEnabled = false

Related Issue

Motivation and Context

Closes #184

  1. Remove vulnerable dependencies
  2. Remove inject-loader and turn those test files into injectable factories
  3. Remove dead code paths on production build
  4. Ensure injectable modules have their required dependencies passed for production bundling
  5. only console.warn once when a deprecated turbine method is accessed
  6. update build & test process

How Has This Been Tested?

Screenshots (if appropriate):

Removing inject-loader

Screenshot 2025-10-02 at 10 16 11 AM

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

This is a major change that could have unforseen consequences. Must review carefully.

Checklist:

Brent Hosie added 2 commits October 1, 2025 20:38
…ectable test modules.

pdcl-13739: integration tests.

pdcl-13739: audit dependencies.
@brenthosie brenthosie requested a review from markhicken October 2, 2025 07:37
@brenthosie brenthosie force-pushed the pdcl-13739 branch 2 times, most recently from ca2e2a9 to 8c5a4c6 Compare October 2, 2025 08:05
@brenthosie brenthosie force-pushed the pdcl-13739 branch 2 times, most recently from b0c8999 to 580db4d Compare October 2, 2025 17:08
Brent Hosie added 2 commits October 2, 2025 13:50
…bled = false. Evict the oldest message first when the buffer of de-duped messages fills.
Copy link
Member Author

@brenthosie brenthosie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When removing inject-loader, here's the general pattern:

old module

var depA = require('./deps/a);
var depb = require('./deps/b);

module.exports = function theThing(runtimeDep) { ... }

New pattern

var validateInjectedParams = require('./helpers/validate-expected-inject-params');

// injectableThing allows us to remove inject-loader
function injectableThing({ depA, depB}) {
  return function theThing(runtimeDep) { ... }
}

var validateInjection = validateInjectedParams(injectableThing);

// since we test using the injectable factory, this ensures we export a fully-ready
// default export for production
module.exports = validateInjection({
  depA: require('./dep/a'),
  depB: require('./dep/b')
});

if (unit_test_mode) {
  // provided for test files
  module.exports.injectableThing = validateInjection;
}

},
plugins: [
new webpack.DefinePlugin({
REACTOR_KARMA_CI_UNIT_TEST_MODE: JSON.stringify(true)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used throughout Turbine now to control if we expose injectable functions or only export the default module with the real run-time dependencies.

name: '_satellite'
},
plugins: [
replace({
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rollup is our production bundler. enusure REACTOR_KARMA_CI_UNIT_TEST_MODE is gone.

* governing permissions and limitations under the License.
****************************************************************************************/

describe(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test file is loaded first in the unit test suite and its job is to ensure that when we call the default export of these injectable modules that they don't throw any errors from our new auto validation function that checks we've injected the right amount of params for production.

/**
* Outputs a warning message to the web console.
* @param {...*} arg Any argument to be logged.
* Outputs a deprecation warning to the web console.
Copy link
Member Author

@brenthosie brenthosie Oct 2, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the original ask of the ticket pdcl-13979: Turbine was too chatty in a production environment because logger.deprecation was allowed to call the console even when setDebug(false) was called. This file now holds up to 100 unique log messages to de-duplicate and ignore. once the buffer fills up, the first entry is ejected to make room for a new call.

The goal here is if we see 5 unique deprecation messages over and over and over, we log each of them once and never again when outputEnabled = false.

'use strict';

// Only run integration tests
var testsContext = require.context(
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The integration test allows us to really boot up Turbine and ensure it doesn't throw any errors while doing so.

@brenthosie brenthosie marked this pull request as ready for review October 2, 2025 20:52
@brenthosie brenthosie force-pushed the pdcl-13739 branch 2 times, most recently from eab607a to e335b5b Compare October 3, 2025 19:57
@brenthosie brenthosie force-pushed the pdcl-13739 branch 2 times, most recently from 5d43346 to 37d5a4b Compare October 3, 2025 22:45
var logDeprecation = function () {
var wasEnabled = outputEnabled;
outputEnabled = true;
var message = arguments[0];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like turbine is already pretty good about telling where deprecation notices came from. Is this ever called by 3rd party extensions?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, it can be called by any 3rd party extension using turbine.logger

/* eslint-disable max-len */
/* eslint-disable no-unused-vars */

const testContainer = {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like the idea of having an in-browser integration test suite, but I'm not sure we should build it out beyond tests that provide more coverage than the existing unit tests.

It would be cool if it was smart enough to receive a real build that came from Forge. Maybe we can use a mock build (container) and also support providing a real build? Or perhaps they are 2 different test tasks? We could make it so integration tests could be called individually from a separate workflow.

Copy link
Member Author

@brenthosie brenthosie Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should at least come up with a few containers that hit major code paths. As an example, this will test the ...ToQueue files because action/condition sequencing is on but this container misses testing things like createRunAction which is synchronous.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Chatty console warnings impact performance

2 participants