Skip to content

Commit 8e84e1a

Browse files
committed
cleaning things up and debugging send queue
1 parent 3b3272a commit 8e84e1a

File tree

9 files changed

+58
-8
lines changed

9 files changed

+58
-8
lines changed

dbux-projects/src/buildTools/WebpackBuilder.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class WebpackBuilder {
7676
'webpack': '^5',
7777
'webpack-cli': '^4',
7878
// 'webpack-config-utils': '???',
79-
// 'copy-webpack-plugin': '^8'
79+
'copy-webpack-plugin': '^8',
80+
'clean-webpack-plugin': '^8'
8081
};
8182
if (this.needsDevServer) {
8283
deps['webpack-dev-server'] = '^3';

dbux-projects/src/projectLib/Project.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -726,9 +726,12 @@ Sometimes a reset (by using the \`Delete project folder\` button) can help fix t
726726
await this.exec(`${this.gitCommand} add ${files.map(name => `"${name}"`).join(' ')}`);
727727

728728
message && (message = ' ' + message);
729+
729730
// TODO: should not need '--allow-empty', if `checkFilesChanged` is correct (but somehow still bugs out)
730731
const errResult = await this.execCaptureErr(`${this.gitCommand} commit -am '"[dbux auto commit]${message}"'`);
731-
this.logger.debug(`commit errResult:###\n${errResult}\n###\n`);
732+
if (errResult.trim()) {
733+
this.logger.debug(`commit errResult:###\n${errResult}\n###\n`);
734+
}
732735
}
733736
}
734737

dbux-projects/src/projects/Editor.md/Project.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,9 @@ import WebpackBuilder from '../../buildTools/WebpackBuilder';
33

44
/**
55
* Debug
6-
*
7-
* console.warn(`cmUnbindScroll ${_dbux2._runtimeMonitor._runtime.peekCurrentContextId()}`);
6+
*
7+
// dbux disable
8+
console.warn(`cmUnbindScroll ${__dbux__._r._runtime.peekCurrentContextId()}`);
89
*/
910

1011
/**

dbux-runtime/src/client/SendQueue.js

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import { newLogger } from '@dbux/common/src/log/logger';
88
const { log, debug, warn, error: logError } = newLogger('Client/queue');
99

1010
const Verbose = 0;
11+
const DEBUG_ROOTS = true;
1112
// const Verbose = 1;
1213
const MAX_BLOCK_SIZE = 65535; // max parameter array size for use in Webkit
1314

@@ -73,15 +74,38 @@ class SendQueue {
7374
return this.buffers.every(buf => isBufferEmpty(buf));
7475
}
7576

76-
bufferDebug(msg) {
77-
debug(`${msg}: ${this.iBufferSent}/${this.iBufferCreated} - ${JSON.stringify(this.bufferMap.entries(), null, 2)}`);
77+
_debugMessages;
78+
_debugLastId;
79+
80+
bufferDebug(msg, flush = true) {
81+
if (DEBUG_ROOTS) {
82+
msg =
83+
`${msg}: ${this.iBufferSent}/${this.iBufferCreated} - ` +
84+
`${JSON.stringify(Array.from(this.bufferMap.entries()), null, 2)}`;
85+
86+
this._debugMessages = this._debugMessages || [];
87+
this._debugMessages.push(msg);
88+
89+
if (flush) {
90+
// flush now
91+
this._debugMessages.forEach(debug);
92+
this._debugMessages = [];
93+
}
94+
}
7895
}
7996

8097
send(dataName, newEntry) {
8198
const buf = this.currentBuffer;
8299
const entries = (buf[dataName] = buf[dataName] || []);
83100
entries.push(newEntry);
84101

102+
if (DEBUG_ROOTS) {
103+
if (dataName === 'executionContexts') {
104+
// TODO: _debugLastId
105+
this.bufferDebug(``, false);
106+
}
107+
}
108+
85109
this._flushLater();
86110
}
87111

dbux-runtime/src/data/executionContextCollection.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,10 +165,11 @@ export class ExecutionContextCollection extends Collection {
165165
const context = this._allocate(
166166
type, stackDepth, runId, parentContextId, parentTraceId, contextId, definitionTid, staticContextId, orderId, schedulerTraceId, tracesDisabled
167167
);
168+
this._pushAndSend(context);
169+
168170
if (!parentContextId) {
169-
this.logger.warn(`CREATE root: ${context.contextId}`, context);
171+
this.logger.warn(`CREATE root: ${context.contextId}`, this.makeContextInfo(contextId));
170172
}
171-
this._pushAndSend(context);
172173

173174
if (this._firstContextChild.get(parentContextId) === undefined) {
174175
this._firstContextChild.set(parentContextId, context.contextId);

dbux-runtime/src/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ const dbux = {
2525
let __global__;
2626

2727
function registerDbuxAsGlobal() {
28+
if (__global__.__dbux__) {
29+
// TODO: add version checking?
30+
// eslint-disable-next-line no-console
31+
console.warn(`@dbux/runtime registered more than once - this could be a bundling deoptimization, or a serious conflict.`);
32+
}
2833
/* eslint-disable no-var */
2934
__global__.__dbux__ = dbux;
3035
}

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
"@babel/preset-env": "^7.10.1",
2424
"@babel/register": "^7.10.1",
2525
"babel-loader": "^8.2.2",
26+
"clean-webpack-plugin": "^4.0.0",
2627
"cloc": "^2.5.1",
2728
"copy-webpack-plugin": "^8",
2829
"css-loader": "^3.4.2",

scripts/killPort.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ console.log(`looking for port=${port}`);
55

66
// TODO: windows only
77
// TODO: consider https://github.com/ksathyanm/find-pid-from-port/blob/main/index.js
8+
/**
9+
* e.g.:
10+
* X = lastWordOf(
11+
* netstat -ano | findstr "TCP" | findStr "3844"
12+
* )
13+
* kill -f X
14+
*/
815
const s = sh.exec(`netstat -ano | findstr "TCP" | findStr "${port}"`);
916
console.log(
1017
s

yarn.lock

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4485,6 +4485,13 @@ clean-stack@^2.0.0:
44854485
resolved "https://registry.yarnpkg.com/clean-stack/-/clean-stack-2.2.0.tgz#ee8472dbb129e727b31e8a10a427dee9dfe4008b"
44864486
integrity sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==
44874487

4488+
clean-webpack-plugin@^4.0.0:
4489+
version "4.0.0"
4490+
resolved "https://registry.yarnpkg.com/clean-webpack-plugin/-/clean-webpack-plugin-4.0.0.tgz#72947d4403d452f38ed61a9ff0ada8122aacd729"
4491+
integrity sha512-WuWE1nyTNAyW5T7oNyys2EN0cfP2fdRxhxnIQWiAp0bMabPdHhoGxM8A6YL2GhqwgrPnnaemVE7nv5XJ2Fhh2w==
4492+
dependencies:
4493+
del "^4.1.1"
4494+
44884495
cli-boxes@^1.0.0:
44894496
version "1.0.0"
44904497
resolved "https://registry.yarnpkg.com/cli-boxes/-/cli-boxes-1.0.0.tgz#4fa917c3e59c94a004cd61f8ee509da651687143"

0 commit comments

Comments
 (0)