Skip to content

Commit 0f7c29f

Browse files
authoredJun 15, 2022
UPDATE node 18.2.0 (#3825)
* UPDATE node 18.2.0 * FIX node.js v18.2.0 problems * FIX test for error * UPDATE dexie js * UPDATE react * UPDATE react-scripts * UPDATE node to 18.3.0 * TRY fix react-native example * FIX ci * FIX ci again
1 parent 51d5b50 commit 0f7c29f

File tree

6 files changed

+31
-22
lines changed

6 files changed

+31
-22
lines changed
 

‎.github/workflows/main.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,8 @@ jobs:
444444
- name: Set node version
445445
uses: actions/setup-node@v3
446446
with:
447-
node-version-file: '.nvmrc'
447+
# TODO using latest node version does not work with react native
448+
node-version: 16.15.0
448449

449450
- name: Reuse npm cache folder
450451
uses: actions/cache@v2

‎.nvmrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v16.15.0
1+
v18.3.0

‎CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
<!-- CHANGELOG NEWEST -->
55

6+
- UPDATE Node.js to version `18.3.0`
67
- FIX: RxStorage should never emit an eventBulk with an empty events array.
78
- Update PouchDB to `7.3.0` Thanks [@cetsupport](https://github.com/cetsupport).
89
- CHANGE (RxStorage) revision hash must not include the `_meta` field.

‎examples/react/package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,13 @@
99
"pouchdb-adapter-idb": "7.2.2",
1010
"pouchdb-replication": "7.2.2",
1111
"pouchdb-server": "4.2.0",
12-
"react": "17.0.2",
13-
"react-dom": "17.0.2",
12+
"react": "18.1.0",
13+
"react-dom": "18.1.0",
1414
"rxdb": "file:rxdb-local.tgz",
1515
"rxjs": "7.5.5"
1616
},
1717
"devDependencies": {
18-
"react-scripts": "4.0.3",
18+
"react-scripts": "5.0.1",
1919
"rimraf": "3.0.2",
2020
"testcafe": "1.18.6",
2121
"local-web-server": "5.1.1"

‎src/util.ts

+19-16
Original file line numberDiff line numberDiff line change
@@ -529,6 +529,8 @@ export function isMaybeReadonlyArray(x: any): x is MaybeReadonly<any[]> {
529529
return Array.isArray(x);
530530
}
531531

532+
533+
const USE_NODE_BLOB_BUFFER_METHODS = typeof FileReader === 'undefined';
532534
export const blobBufferUtil = {
533535
/**
534536
* depending if we are on node or browser,
@@ -547,16 +549,16 @@ export const blobBufferUtil = {
547549
} as any);
548550
}
549551

550-
try {
551-
// for browsers
552-
blobBuffer = new Blob([data], {
553-
type
554-
} as any);
555-
} catch (e) {
552+
if (USE_NODE_BLOB_BUFFER_METHODS) {
556553
// for node
557554
blobBuffer = Buffer.from(data, {
558555
type
559556
} as any);
557+
} else {
558+
// for browsers
559+
blobBuffer = new Blob([data], {
560+
type
561+
} as any);
560562
}
561563

562564
return blobBuffer;
@@ -578,23 +580,23 @@ export const blobBufferUtil = {
578580
);
579581
}
580582

581-
try {
583+
584+
if (USE_NODE_BLOB_BUFFER_METHODS) {
585+
// for node
586+
blobBuffer = Buffer.from(
587+
base64String,
588+
'base64'
589+
);
590+
return blobBuffer;
591+
} else {
582592
/**
583593
* For browsers.
584594
* @link https://ionicframework.com/blog/converting-a-base64-string-to-a-blob-in-javascript/
585595
*/
586596
const base64Response = await fetch(`data:${type};base64,${base64String}`);
587597
const blob = await base64Response.blob();
588598
return blob;
589-
} catch (e) {
590-
// for node
591-
blobBuffer = Buffer.from(
592-
base64String,
593-
'base64'
594-
);
595599
}
596-
597-
return blobBuffer;
598600
},
599601
isBlobBuffer(data: any): boolean {
600602
if ((typeof Buffer !== 'undefined' && Buffer.isBuffer(data)) || data instanceof Blob) {
@@ -607,7 +609,8 @@ export const blobBufferUtil = {
607609
if (typeof blobBuffer === 'string') {
608610
return Promise.resolve(blobBuffer);
609611
}
610-
if (typeof Buffer !== 'undefined' && blobBuffer instanceof Buffer) {
612+
613+
if (USE_NODE_BLOB_BUFFER_METHODS) {
611614
// node
612615
return nextTick()
613616
.then(() => blobBuffer.toString());

‎test/unit/replication-graphql.test.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ import {
3939
import {
4040
getLastPullDocument,
4141
getLastPushCheckpoint,
42+
RxReplicationError,
4243
setLastPullDocument
4344
} from '../../plugins/replication';
4445
import * as schemas from '../helper/schemas';
@@ -1413,7 +1414,10 @@ describe('replication-graphql.test.ts', () => {
14131414
first()
14141415
).toPromise();
14151416

1416-
assert.ok(ensureNotFalsy(error).toString().includes('foobar'));
1417+
if (!error || (error as RxReplicationError<any>).type !== 'pull') {
1418+
console.dir(error);
1419+
throw error;
1420+
}
14171421

14181422
replicationState.cancel();
14191423
c.database.destroy();

0 commit comments

Comments
 (0)
Please sign in to comment.