Experimental technological stack, including:
- Application Server Impress
- Client Run-time Console
- JavaScript Transfer Protocol JSTP
- Database Management System GlobalStorage
Metarhia application example for Node.js 🟢
Home Page: https://metarhia.com
License: MIT License
Experimental technological stack, including:
.gitignore is supposed to remove /application/tasks from being tracked, but the folder is still tracked because .gitkeep was added there before the .gitignore rule.
The solution is probably to use:
git rm -r --cached application/tasks
or remove /application/tasks from .gitignore to continue keeping this folder.
Introspection return arguments so we can use this metadata to generate client-side stubs.
Steps:
upload
application/resources
folderServer console:
8:53 W2 log 127.0.0.1 files/upload
13:58:53 W2 error 127.0.0.1 GET /api 400 400 Error: Stream -2097281614 is not initialized
WsChannel.binary (/node_modules/metacom/lib/channel.js:159:23)
WebSocket.<anonymous> (/node_modules/metacom/lib/ws.js:10:26)
WebSocket.emit (node:events:390:28)
Receiver.receiverOnMessage (/node_modules/ws/lib/websocket.js:1180:20)
Receiver.emit (node:events:390:28)
Receiver.dataMessage (/node_modules/ws/lib/receiver.js:526:14)
Receiver.getData (/node_modules/ws/lib/receiver.js:459:17)
Receiver.startLoop (/node_modules/ws/lib/receiver.js:158:22)
Receiver._write (/node_modules/ws/lib/receiver.js:84:10)
writeOrBuffer (node:internal/streams/writable:389:12)
13:58:54 W1 debug Reload: /resources/icon.svg
13:58:57 W2 debug Heap: 11 Mb of 12 Mb, ext: 2 Mb
13:58:57 W3 debug Heap: 10 Mb of 12 Mb, ext: 2 Mb
13:58:57 W2 debug Contexts: 5, detached: 0
13:58:57 W3 debug Contexts: 5, detached: 0
13:58:57 W5 debug Heap: 10 Mb of 12 Mb, ext: 2 Mb
13:58:57 W5 debug Contexts: 5, detached: 0
13:58:57 W1 debug Heap: 10 Mb of 12 Mb, ext: 2 Mb
13:58:57 W1 debug Contexts: 5, detached: 0
13:58:57 W4 debug Heap: 10 Mb of 12 Mb, ext: 2 Mb
13:58:57 W4 debug Contexts: 5, detached: 0
Env:
(base) ➜ Example git:(master) ✗ node -v
npmv16.13.0
(base) ➜ Example git:(master) ✗ npm -v
8.1.0
ws client:
{"stream":1,"name":"icon.svg","size":1454}
{"call":5,"files/upload":{"streamId":1,"name":"icon.svg"}}
Binary Message
{"stream":1,"status":"end"}
{"callback":-2097281614,"error":{"message":"Stream -2097281614 is not initialized","code":400}}
async () => {
setInterval(() => {
const stats = lib.resmon.getStatistics();
context.client.emit('example/resmon', stats);
}, config.resmon.interval);
return { subscribed: 'resmon' };
};
In this case, if we reload page, we have error:
10:37:21 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:10:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
We can add try/catch to fix timer:
async () => {
const timer = setInterval(() => {
const stats = lib.resmon.getStatistics();
try { context.client.emit('example/resmon', stats); }
catch (e) { clearInterval(timer) };
}, config.resmon.interval);
return { subscribed: 'resmon' };
};
file package.json
packet impress
in current master branch Example use Impress 2.2.0 current version of Impress is 2.3.0
node v18.12.1
OS: WSL 2 Ubuntu
09:13:42 W1 debug Start example plugin
09:13:42 W1 debug { set: { key: 'keyName', val: 123 } }
09:13:42 W1 debug { get: 'keyName', return: 123 }
09:13:42 W1 debug { res: 123, cache: Map(1) { 'keyName' => 123 } }
09:13:42 W1 debug Connect to pg
09:13:42 W1 debug Connect to redis
09:13:42 W4 info Application started in worker 4
09:13:42 W2 info Application started in worker 2
09:13:42 W3 info Application started in worker 3
09:13:42 W2 info Listen port 8001
09:13:42 W3 info Listen port 8002
09:13:42 W4 debug lib.invoke1.method1 { key: 'value' }
09:13:42 W5 info Application started in worker 5
09:13:43 W1 log Add task 2023-01-07-id-1
09:13:43 W1 error unhandledRejection: Error: socket hang up
connResetException (node:internal/errors:711:14)
Socket.socketOnEnd (node:_http_client:518:23)
Socket.emit (node:events:525:35)
endReadableNT (node:internal/streams/readable:1359:12)
process.processTicksAndRejections (node:internal/process/task_queues:82:21)
09:13:43 W1 info Initialization failed in worker 1
09:13:43 W1 debug Stop example plugin
09:13:43 W0 info Can not start Application server
or
09:14:03 W1 debug Start example plugin
09:14:03 W1 debug { set: { key: 'keyName', val: 123 } }
09:14:04 W1 debug { get: 'keyName', return: 123 }
09:14:04 W1 debug { res: 123, cache: Map(1) { 'keyName' => 123 } }
09:14:04 W1 debug Connect to pg
09:14:04 W1 debug Connect to redis
09:14:04 W2 info Application started in worker 2
09:14:04 W2 info Listen port 8001
09:14:04 W4 info Application started in worker 4
09:14:04 W5 info Application started in worker 5
09:14:04 W3 info Application started in worker 3
09:14:04 W4 debug lib.invoke1.method1 { key: 'value' }
09:14:04 W3 info Listen port 8002
09:14:05 W1 log Add task 2023-01-07-id-2
09:14:05 W1 error unhandledRejection: Error: read ECONNRESET
TCP.onStreamRead (node:internal/stream_base_commons:217:20)
09:14:05 W1 info Initialization failed in worker 1
09:14:05 W1 debug Stop example plugin
09:14:05 W0 info Can not start Application server
Refused to connect to 'https://fonts.googleapis.com/css?family=Share+Tech+Mono'
because it violates the following Content Security Policy directive: "default-src 'self' ws:".
Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
Example project has tests for API in the application/domain/tests
folder. Specifically two tests http.test.js
and ws.test.js
running the same test cases from api.js
, e.g.
Example/application/domain/tests/api.js
Lines 11 to 14 in 2435b8e
It seems that Call example.add({ a, b })
don't execute during test run.
npm t
Call example.add({ a, b })
test mentioning in the console logs despite that Metacom over HTTP
and Metacom over Websocket
marked as passed.11:52:24 W1 debug ✅ Passed: Get room with domain.chat.getRoom (0.251542ms)
11:52:24 W1 debug ✅ Passed: Send message with domain.chat.send (0.097667ms)
11:52:24 W1 debug ✅ Passed: Chat test (1.12525ms)
11:52:24 W2 debug 127.0.0.1 POST /api 200
11:52:24 W2 log 127.0.0.1 system/introspect
11:52:24 W1 debug ✅ Passed: Metacom over HTTP (17.8425ms)
11:52:24 W1 debug 127.0.0.1 GET /demo.txt 200
11:52:24 W1 debug ✅ Passed: Test to serve without cache (7.318167ms)
11:52:24 W3 debug 127.0.0.1 GET / 200
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/ (7.025792ms)
11:52:24 W1 debug 127.0.0.1 GET /console.js 200
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/console.js (2.40575ms)
11:52:24 W1 error 127.0.0.1 GET /unknown 404
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/unknown (2.39425ms)
11:52:24 W1 error 127.0.0.1 GET /unknown.png 404
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/unknown.png (2.170125ms)
11:52:24 W1 error 127.0.0.1 GET /unknown/unknown 404
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/unknown/unknown (1.154375ms)
11:52:24 W1 error 127.0.0.1 GET /unknown/unknown.png 404
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/unknown/unknown.png (1.115292ms)
11:52:24 W1 debug 127.0.0.1 GET /article 200
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/article (1.617167ms)
11:52:24 W1 debug 127.0.0.1 GET /article/file.txt 200
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/article/file.txt (2.123542ms)
11:52:24 W1 debug 127.0.0.1 GET /article/name 200
11:52:24 W1 debug ✅ Passed: Get static resource: http://127.0.0.1:8000/article/name (1.464959ms)
11:52:24 W1 debug ✅ Passed: Static server test (30.391125ms)
11:52:24 W2 log 127.0.0.1 system/introspect
11:52:24 W1 debug ✅ Passed: Metacom over Websocket (5.606583ms)
11:52:24 W1 debug 🟢 Passed 16, Failed: 0
OS: macOS 14.1.2
Node: 20.9.0
To have handy access to accountId.
Discussion #144
Node version: 14.15.3
OS: MacOS 11.2.1
In Example directory:
Example version: 1.1.2
"devDependencies": {
"@types/node": "^14.14.31",
"eslint": "^7.21.0",
"metatests": "^0.7.2"
},
"dependencies": {
"impress": "^2.0.11",
"metasql": "^0.3.0-alpha.3",
"redis": "^3.0.2"
}
Metacom:
"name": "metacom",
"version": "1.5.3",
await api.example.subscribe()
23:55:42 W2 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
Full console:
00:09:27 W3 info Listen port 7002 in worker 3
00:09:27 W1 info Listen port 7000 in worker 1
00:09:27 W2 info Listen port 7001 in worker 2
00:09:27 W1 debug Start example plugin
00:09:27 W1 debug { set: { key: 'keyName', val: 100 } }
00:09:27 W1 debug { get: 'keyName', return: 100 }
00:09:27 W1 debug { res: 100, cache: undefined }
00:09:27 W1 debug Connect to redis
00:09:27 W1 debug Connect to pg
00:09:27 W1 debug Connect to metacom
00:09:27 W2 log 127.0.0.1 system/introspect
00:09:27 W3 info Application started in worker 3
00:09:27 W2 log 127.0.0.1 system/introspect
00:09:27 W2 log 127.0.0.1 system/introspect
00:09:27 W2 log 127.0.0.1 system/introspect
00:09:27 W4 info Application started in worker 4
00:09:27 W1 info Application started in worker 1
00:09:27 W2 info Application started in worker 2
00:09:27 W2 log 127.0.0.1 system/introspect
00:09:27 W5 info Application started in worker 5
00:09:49 W3 log 127.0.0.1 GET /
00:09:50 W3 log 127.0.0.1 GET /console.css
00:09:50 W3 log 127.0.0.1 GET /console.js
00:09:50 W3 log 127.0.0.1 GET /metarhia.svg
00:09:50 W3 log 127.0.0.1 GET /metacom.js
00:09:50 W3 log 127.0.0.1 GET /events.js
00:09:50 W3 log 127.0.0.1 GET /manifest.json
00:09:50 W3 log 127.0.0.1 system/introspect
00:09:50 W3 debug SELECT data FROM "SystemSession" WHERE token = $1 [jaj1rzAZciWBSVX2bWtwslsulwU2IIib4VLaYwTFtxszi5kdBeodayvNK5y516ad]
00:09:50 W3 log 127.0.0.1 GET /metarhia.png
00:09:50 W3 log 127.0.0.1 auth/restore
00:09:50 W3 log 127.0.0.1 console/content
00:09:52 W3 log 127.0.0.1 GET /worker.js
00:10:02 W3 log 127.0.0.1 example/subscribe
00:10:07 W3 log 127.0.0.1 GET /
00:10:07 W3 log 127.0.0.1 GET /console.css
00:10:07 W3 log 127.0.0.1 GET /console.js
00:10:07 W3 log 127.0.0.1 GET /metarhia.svg
00:10:07 W3 log 127.0.0.1 GET /metacom.js
00:10:07 W3 log 127.0.0.1 GET /events.js
00:10:07 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:07 W3 log 127.0.0.1 GET /manifest.json
00:10:07 W3 log 127.0.0.1 GET /favicon.ico
00:10:07 W3 log 127.0.0.1 system/introspect
00:10:07 W3 debug SELECT data FROM "SystemSession" WHERE token = $1 [jaj1rzAZciWBSVX2bWtwslsulwU2IIib4VLaYwTFtxszi5kdBeodayvNK5y516ad]
00:10:07 W3 log 127.0.0.1 GET /metarhia.png
00:10:07 W3 log 127.0.0.1 GET /favicon.ico
00:10:07 W3 log 127.0.0.1 auth/restore
00:10:07 W3 log 127.0.0.1 console/content
00:10:08 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:09 W3 log 127.0.0.1 GET /worker.js
00:10:09 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:09 W1 info Graceful shutdown in worker 1
00:10:09 W2 info Graceful shutdown in worker 2
00:10:09 W3 info Graceful shutdown in worker 3
00:10:09 W4 info Graceful shutdown in worker 4
00:10:09 W5 info Graceful shutdown in worker 5
00:10:09 W1 debug Stop example plugin
00:10:09 W2 debug Stop example plugin
00:10:09 W3 debug Stop example plugin
00:10:10 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:11 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:12 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:13 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
00:10:14 W3 error TypeError: Cannot read property 'connection' of undefined
Client.emit (/node_modules/metacom/lib/channel.js:75:18)
Timeout._onTimeout (/application/api/example.1/subscribe.js:4:20)
listOnTimeout (internal/timers.js:554:17)
processTimers (internal/timers.js:497:7)
Metacom doesn't return an array with some objects; it triggers a timeout.
I added a test for Metacom during startup, which calls api/partner/getPartnersByOffer.js
, but the request is not being processed.
The data for the response is located in lib/partner/getPartners.js
.
Link to the repository: https://github.com/slavakaderkin/Example
I ran the code on macOS Ventura 13.5.
Eliminate render-blocking resources:
1.1 google fonts "/css?family=Share+Tech+Mono"
transfer the fonts to the server or apply the system fonts
1.2 use preload for /console.css
Enable text compression.
it would be good to use brotli compress
Use modern HTTP/2
The plain password must not be transferred to the 3rd-party code.
This code must use node-embedded functions to get hash and compare it with the stored one.
By the way the password must be salted.
First function in module now becoming root and we can't access it by its name.
metasql need logging with Metarhia Logger interface from metalog
worker.js:15 Uncaught (in promise) DOMException:
Failed to execute 'waitUntil' on 'ExtendableEvent':
The event handler is already finished and no extend lifetime promises are outstanding.
at http://127.0.0.1:8001/worker.js:15:9
#268
At this moment, we have so simplified auth example. I propose to improve it to more realistic by adding more fields to model like:
Also would be nice:
Remove interface and method names from URL
Body format JSON, specs here: https://github.com/metarhia/Contracts/blob/master/doc/Metacom.md
Start from this commit example server have this errors. In latest version in master branch this errors just 4 times occurs, then server crashed. In older version (from adding redis example to update impress 2.0.3) this errors infinity occurs, but server working. I have no redis installed locally. Readme doesn't say anything about it.
Well, I didn't want to deal with redis at all. I was interested in other examples. If these errors concern redis, it may be worth somehow disabling examples with redis if it is not installed locally, or mention redis installation in readme.
21:03:59 W3 info Listen port 8002 in worker 3
21:03:59 W2 info Listen port 8001 in worker 2
21:03:59 W1 error Can not load TLS certificates
21:03:59 W1 info Listen port 8000 in worker 1
21:03:59 W3 log Start example plugin
21:03:59 W3 log { set: { key: 'keyName', val: 100 } }
21:03:59 W3 log { get: 'keyName' }
21:03:59 W3 log { return: 100 }
21:03:59 W3 log { res: 100, cache: undefined }
21:03:59 W3 log Connect to redis
21:03:59 W3 debug Connect to pg
21:03:59 W3 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W4 log Start example plugin
21:03:59 W4 log { set: { key: 'keyName', val: 100 } }
21:03:59 W4 log { get: 'keyName' }
21:03:59 W4 log { return: 100 }
21:03:59 W4 log { res: 100, cache: undefined }
21:03:59 W4 log Connect to redis
21:03:59 W4 debug Connect to pg
21:03:59 W4 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W2 log Start example plugin
21:03:59 W1 log Start example plugin
21:03:59 W2 log { set: { key: 'keyName', val: 100 } }
21:03:59 W2 log { get: 'keyName' }
21:03:59 W2 log { return: 100 }
21:03:59 W2 log { res: 100, cache: undefined }
21:03:59 W2 log Connect to redis
21:03:59 W2 debug Connect to pg
21:03:59 W2 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W5 log Start example plugin
21:03:59 W1 log { set: { key: 'keyName', val: 100 } }
21:03:59 W1 log { get: 'keyName' }
21:03:59 W1 log { return: 100 }
21:03:59 W1 log { res: 100, cache: undefined }
21:03:59 W1 log Connect to redis
21:03:59 W1 debug Connect to pg
21:03:59 W1 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W5 log { set: { key: 'keyName', val: 100 } }
21:03:59 W5 log { get: 'keyName' }
21:03:59 W5 log { return: 100 }
21:03:59 W5 log { res: 100, cache: undefined }
21:03:59 W5 log Connect to redis
21:03:59 W5 debug Connect to pg
21:03:59 W5 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W3 debug Connect to metacom
21:03:59 W2 log 127.0.0.1 anonymous system/introspect
21:03:59 W3 info Application started in worker 3
21:03:59 W4 debug Connect to metacom
21:03:59 W2 debug Connect to metacom
21:03:59 W2 log 127.0.0.1 anonymous system/introspect
21:03:59 W4 info Application started in worker 4
21:03:59 W2 log 127.0.0.1 anonymous system/introspect
21:03:59 W2 info Application started in worker 2
21:03:59 W1 debug Connect to metacom
21:03:59 W5 debug Connect to metacom
21:03:59 W2 log 127.0.0.1 anonymous system/introspect
21:03:59 W2 log 127.0.0.1 anonymous system/introspect
21:03:59 W1 info Application started in worker 1
21:03:59 W5 info Application started in worker 5
21:03:59 W3 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W4 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W2 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W1 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:03:59 W5 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W3 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W4 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W2 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W1 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W5 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W3 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W4 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W2 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W1 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
21:04:00 W5 error Error: connect ECONNREFUSED 127.0.0.1:6379
TCPConnectWrap.afterConnect [as oncomplete] (node:net:1139:16)
When start docker-compose
api-example | /usr/server/node_modules/impress/lib/deps.js:95
api-example | node.timers.promises = require('node:timers/promises');
api-example | ^
api-example |
api-example | TypeError: Cannot set property promises of #<Object> which has only a getter
api-example | at Object.<anonymous> (/usr/server/node_modules/impress/lib/deps.js:95:22)
api-example | at Module._compile (node:internal/modules/cjs/loader:1369:14)
api-example | at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
api-example | at Module.load (node:internal/modules/cjs/loader:1206:32)
api-example | at Module._load (node:internal/modules/cjs/loader:1022:12)
api-example | at Module.require (node:internal/modules/cjs/loader:1231:19)
api-example | at require (node:internal/modules/helpers:179:18)
api-example | at Object.<anonymous> (/usr/server/node_modules/impress/lib/planner.js:3:32)
api-example | at Module._compile (node:internal/modules/cjs/loader:1369:14)
api-example | at Module._extensions..js (node:internal/modules/cjs/loader:1427:10)
api-example |
api-example | Node.js v20.12.1
in the session recovery example, potential error
application/api/auth.2/restore.js
({
access: 'public',
method: async ({ token }) => {
const restored = context.client.restoreSession(token);
if (restored) return { status: 'logged' };
const data = await api.auth.provider.readSession(token);
return { status: data ? 'logged' : 'not logged' };
},
});
If the token is not in sessions, we check it in the database, but after that we don't add it to sessions.
Example: context.client.startSession(token, data);
const api = connect(['system', 'auth', 'example']);
await api.auth.signIn({ login, password });
const interfaces = await api.system.getInterfaces();
We use metacom for inter-process communication, need and example, how to use it as a plugin.
Never resolves await application.init();
Even no message:
09:10:50 W1 system Application started in worker 1
If callId is not registered in this.calls
, following code const [resolve, reject] = this.calls.get(callId);
will fail with error: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
Refs: HowProgrammingWorks/NodejsStarterKit#162
Client-side need access session token, pass it to RPC (by websocket) and set new token (received from websocket) so httpOnly cookies in not suitable for this.
It seems that db.pg.update (provider.js) doesn't return a promise, so we do not call the method then() in class Modify (database.js)
Help me pls understand what is wrong
In the counter example, does not store context to the DB
thx
config, application, npm, node, api, domain, lib
npm, node, api, domain
console, global
Error, Buffer, URL, URLSearchParams, TextDecoder,TextEncoder
setTimeout, setImmediate, setInterval, clearTimeout, clearImmediate, clearInterval, queueMicrotask
Приветствую! Вы не могли бы набросать docker-compose.yml, чтоб любой желающий смог в одно нажатие все запустить и увидеть хоть что-то рабочее? Например, у меня на пути встал postgresql. В одно нажатие он не запустился, а разбираться с ним вообще не хочется.
I created a directory "img" in the static directory, added pictures there. But the file index.html did not create. When i navigate to the \img\ url, the browser waits for the page indefinitely. On the node server it gives an error:
07:52:22 W1 error unhandledRejection: RangeError [ERR_OUT_OF_RANGE]: The value of "end" is out of range. It must be >= 0 && <= 9007199254740991. Received -1
new ReadStream (node:internal/fs/streams:201:5)
Object.createReadStream (node:fs:3060:10)
Static.serve (\node_modules\impress\lib\static.js:76:32)
OS: BigSur 11.2.3
node v15.14.0
19:05:21 W2 info Listen port 8001 in worker 2
19:05:21 W1 info Listen port 8000 in worker 1
19:05:21 W3 info Listen port 8002 in worker 3
19:05:21 W1 debug Start example plugin
19:05:21 W1 debug { set: { key: 'keyName', val: 100 } }
19:05:21 W1 debug { get: 'keyName', return: 100 }
19:05:21 W1 debug { res: 100, cache: undefined }
19:05:21 W1 debug Connect to redis
19:05:21 W1 debug Connect to pg
19:05:21 W1 warn No redis service detected, so quit client
19:05:21 W1 debug Connect to metacom
19:05:22 W5 error Error [ERR_UNHANDLED_ERROR]: Unhandled error. (ErrorEvent {
target: WebSocket {
_events: [Object: null prototype] { message: [Function], error: [Array] },
_eventsCount: 2,
_maxListeners: undefined,
_binaryType: 'nodebuffer',
_closeCode: 1006,
_closeFrameReceived: false,
_closeFrameSent: false,
_closeMessage: '',
_closeTimer: null,
_extensions: {},
_protocol: '',
_readyState: 2,
_receiver: null,
_sender: null,
_socket: null,
_bufferedAmount: 0,
_isServer: false,
_redirects: 0,
_url: 'ws://localhost:8001',
_req: ClientRequest {
_events: [Object: null prototype],
_eventsCount: 5,
_maxListeners: undefined,
outputData: [],
outputSize: 0,
writable: true,
destroyed: true,
_last: true,
chunkedEncoding: false,
shouldKeepAlive: true,
_defaultKeepAlive: true,
useChunkedEncodingByDefault: false,
sendDate: false,
_removedConnection: false,
_removedContLen: false,
_removedTE: false,
_contentLength: 0,
_hasBody: true,
_trailer: '',
finished: true,
_headerSent: true,
_closed: false,
socket: [Socket],
_header: 'GET / HTTP/1.1\r\n' +
'Sec-WebSocket-Version: 13\r\n' +
'Sec-WebSocket-Key: a3Nqj19jf3Be5inH15p34Q==\r\n' +
'Connection: Upgrade\r\n' +
'Upgrade: websocket\r\n' +
'Sec-WebSocket-Extensions: permessage-deflate; client_max_window_bits\r\n' +
'Host: localhost:8001\r\n' +
'\r\n',
_keepAliveTimeout: 0,
_onPendingData: {},
agent: undefined,
socketPath: undefined,
method: 'GET',
maxHeaderSize: undefined,
insecureHTTPParser: undefined,
path: '/',
_ended: false,
res: [IncomingMessage],
aborted: true,
timeoutCb: null,
upgradeOrConnect: false,
parser: [HTTPParser],
maxHeadersCount: null,
reusedSocket: false,
host: 'localhost',
protocol: 'http:',
[Symbol(kCapture)]: false,
[Symbol(kNeedDrain)]: false,
[Symbol(corked)]: 0,
[Symbol(kOutHeaders)]: [Object: null prototype],
[Symbol(kError)]: undefined
},
[Symbol(kCapture)]: false
},
type: 'error',
message: 'Unexpected server response: 200',
error: Error: Unexpected server response: 200
ClientRequest.<anonymous> (/node_modules/ws/lib/websocket.js:604:7)
ClientRequest.emit (node:events:369:20)
HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:646:27)
HTTPParser.parserOnHeadersComplete (node:_http_common:129:17)
Socket.socketOnData (node:_http_client:512:22)
Socket.emit (node:events:369:20)
addChunk (node:internal/streams/readable:313:12)
readableAddChunk (node:internal/streams/readable:288:9)
Socket.Readable.push (node:internal/streams/readable:227:10)
TCP.onStreamRead (node:internal/stream_base_commons:190:23)
})
new NodeError (node:internal/errors:329:5)
Metacom.emit (node:events:358:17)
WebSocket.<anonymous> (/node_modules/metacom/lib/client.js:59:12)
WebSocket.onError (/node_modules/ws/lib/event-target.js:140:16)
WebSocket.emit (node:events:381:22)
abortHandshake (/node_modules/ws/lib/websocket.js:722:15)
ClientRequest.<anonymous> (/node_modules/ws/lib/websocket.js:604:7)
ClientRequest.emit (node:events:369:20)
HTTPParser.parserOnIncomingClient [as onIncoming] (node:_http_client:646:27)
HTTPParser.parserOnHeadersComplete (node:_http_common:129:17)
user@MacBook-Air Example %
Caught an error in application/domain/database/start.js after starting the server, it seems there was no metasql injection
TypeError: Cannot read property 'Database' of undefined Object.<anonymous> (start:5:41)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.