Skip to content

Commit

Permalink
Merge pull request #784 from splitio/development
Browse files Browse the repository at this point in the history
Release v10.25.0
  • Loading branch information
EmilianoSanchez committed Jan 4, 2024
2 parents 421dc7d + 28592cf commit 0364d67
Show file tree
Hide file tree
Showing 10 changed files with 91 additions and 61 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/update-license-year.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v4
with:
fetch-depth: 0

Expand All @@ -24,7 +24,7 @@ jobs:
run: "echo PREVIOUS=$(($CURRENT-1)) >> $GITHUB_ENV"

- name: Update LICENSE
uses: jacobtomlinson/gha-find-replace@v2
uses: jacobtomlinson/gha-find-replace@v3
with:
find: ${{ env.PREVIOUS }}
replace: ${{ env.CURRENT }}
Expand All @@ -38,7 +38,7 @@ jobs:
git commit -m "Updated License Year" -a
- name: Create Pull Request
uses: peter-evans/create-pull-request@v3
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: Update License Year
Expand Down
3 changes: 3 additions & 0 deletions CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
10.25.0 (January 4, 2024)
- Updated SDK to support URLs without TLS protocol in NodeJS, to simplify proxy usage inside private networks.

10.24.1 (December 12, 2023)
- Updated SDK cache for browsers using localStorage, to clear cached feature flag definitions before initiating the synchronization process if the cache was previously synchronized with a different SDK key (i.e., a different environment) or different Split Filter criteria, to avoid using invalid cached data when the SDK is ready from cache.
- Updated @splitsoftware/splitio-commons package to version 1.12.1.
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Copyright © 2023 Split Software, Inc.
Copyright © 2024 Split Software, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand Down
62 changes: 31 additions & 31 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@splitsoftware/splitio",
"version": "10.24.1",
"version": "10.25.0",
"description": "Split SDK",
"files": [
"README.md",
Expand Down Expand Up @@ -40,20 +40,20 @@
"node": ">=6"
},
"dependencies": {
"@splitsoftware/splitio-commons": "1.12.1",
"@splitsoftware/splitio-commons": "1.13.0",
"@types/google.analytics": "0.0.40",
"@types/ioredis": "^4.28.0",
"bloom-filters": "^3.0.0",
"ioredis": "^4.28.0",
"js-yaml": "^3.13.1",
"node-fetch": "^2.6.7",
"node-fetch": "^2.7.0",
"unfetch": "^4.2.0"
},
"optionalDependencies": {
"eventsource": "^1.1.2"
},
"devDependencies": {
"@types/node-fetch": "^2.5.12",
"@types/node-fetch": "^2.6.10",
"@types/seedrandom": "^3.0.2",
"copyfiles": "^2.4.1",
"cross-env": "^7.0.3",
Expand Down
31 changes: 28 additions & 3 deletions src/platform/getFetch/__tests__/node.spec.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,33 @@
import tape from 'tape-catch';
import { getFetch } from '../node';
import sinon from 'sinon';
import { getFetch, __setFetch } from '../node';

tape('getFetch returns node-fetch module in Node', assert => {
assert.equal(getFetch(), require('node-fetch'));
tape('getFetch returns a wrapped node-fetch module in Node', assert => {
assert.equal(typeof getFetch(), 'function');

assert.end();
});

tape('getFetch passes an agent object to HTTPs requests', assert => {
const fetchMock = sinon.stub();
__setFetch(fetchMock);

const fetch = getFetch();

fetch('http://test.com');
assert.true(fetchMock.calledWithExactly('http://test.com', { agent: undefined }));

fetch('https-https://', { option: 'value' });
assert.true(fetchMock.calledWithExactly('https-https://', { option: 'value', agent: undefined }));

fetch('https://test.com');
assert.true(fetchMock.calledWithExactly('https://test.com', { agent: sinon.match.object }));

fetch('https://test.com', { option: 'value' });
assert.true(fetchMock.calledWithExactly('https://test.com', { option: 'value', agent: sinon.match.object }));

// Restore
__setFetch(require('node-fetch'));

assert.end();
});
21 changes: 20 additions & 1 deletion src/platform/getFetch/node.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
/* eslint-disable compat/compat */
import https from 'https';

// @TODO
// 1- handle multiple protocols automatically
// 2- destroy it once the sdk is destroyed
const agent = new https.Agent({
keepAlive: true,
keepAliveMsecs: 1500
});

let nodeFetch;

try {
Expand All @@ -16,6 +27,14 @@ export function __setFetch(fetch) {
nodeFetch = fetch;
}

/**
* Retrieves 'node-fetch', a Fetch API polyfill for NodeJS, with fallback to global 'fetch' if available.
* It passes an https agent with keepAlive enabled if URL is https.
*/
export function getFetch() {
return nodeFetch;
if (nodeFetch) {
return (url, options) => {
return nodeFetch(url, Object.assign({ agent: url.startsWith('https:') ? agent : undefined }, options));
};
}
}
2 changes: 0 additions & 2 deletions src/platform/node.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import EventEmitter from 'events';
import { getFetch } from '../platform/getFetch/node';
import { getEventSource } from '../platform/getEventSource/node';
import { getOptions } from '../platform/request/options/node';
import { NodeSignalListener } from '@splitsoftware/splitio-commons/src/listeners/node';
import { now } from '@splitsoftware/splitio-commons/src/utils/timeTracker/now/node';

export const platform = {
getOptions,
getFetch,
getEventSource,
EventEmitter,
Expand Down
15 changes: 0 additions & 15 deletions src/platform/request/options/node.js

This file was deleted.

2 changes: 1 addition & 1 deletion src/settings/defaults/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export const packageVersion = '10.24.1';
export const packageVersion = '10.25.0';

0 comments on commit 0364d67

Please sign in to comment.