feat(session): Phase 456 startup/register/open spans and search cache reset (v0.8.419)
session.startup ends with guildCount/guildId; identity.register and guild.open error logs; loadGuild/createGuild clear _lastSearchFromCache after cache bust. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
@@ -35,6 +35,8 @@ Expose a single `EventEmitter` API the UI drives over IPC (`apps/pearcord/index.
|
|||||||
| `onboarded`, `identity`, `storagePath`, `db`, `dbPath` | Session state |
|
| `onboarded`, `identity`, `storagePath`, `db`, `dbPath` | Session state |
|
||||||
| `listGuilds()`, `loadGuild(guildId)`, `createGuild({ name, publicListing? })`, `joinInvite(code)` | Guild session |
|
| `listGuilds()`, `loadGuild(guildId)`, `createGuild({ name, publicListing? })`, `joinInvite(code)` | Guild session |
|
||||||
|
|
||||||
|
**v0.8.419 (Phase 456):** `session.startup` span ends with `guildCount` + `guildId`; `session.startup error` log. `identity.register` span + `identity.register error`. `guild.open` span end includes `guildId`. `loadGuild` / `createGuild` bust search cache and clear `_lastSearchFromCache`. Bundle: `npm run test:phase456-onboarding-session`. See [SESSION.md](../../docs/SESSION.md).
|
||||||
|
|
||||||
### Messaging & channels
|
### Messaging & channels
|
||||||
|
|
||||||
| Method | Role |
|
| Method | Role |
|
||||||
|
|||||||
@@ -503,10 +503,15 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const startupGuildMeshBounded = !!this._lastGuildMeshFlushBounded
|
const startupGuildMeshBounded = !!this._lastGuildMeshFlushBounded
|
||||||
span.end({
|
span.end({
|
||||||
logLevel: startupGuildMeshBounded ? 'info' : undefined,
|
logLevel: startupGuildMeshBounded ? 'info' : undefined,
|
||||||
guildMeshBounded: startupGuildMeshBounded
|
guildMeshBounded: startupGuildMeshBounded,
|
||||||
|
guildCount: this.guilds?.length || 0,
|
||||||
|
guildId: this.guild?.guild?.id || null
|
||||||
})
|
})
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this._sessionError = err?.message || String(err)
|
this._sessionError = err?.message || String(err)
|
||||||
|
this.log.error('session.startup error', {
|
||||||
|
err: err?.message || String(err)
|
||||||
|
})
|
||||||
this.log.error('session startup failed', { err })
|
this.log.error('session startup failed', { err })
|
||||||
this.emit('session-error', err)
|
this.emit('session-error', err)
|
||||||
span.fail(err)
|
span.fail(err)
|
||||||
@@ -1107,10 +1112,24 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async registerUser ({ username, displayName }) {
|
async registerUser ({ username, displayName }) {
|
||||||
|
const span = this.log.time('identity.register', {
|
||||||
|
username: username || null
|
||||||
|
})
|
||||||
|
try {
|
||||||
const user = await this.identity.register({ username, displayName })
|
const user = await this.identity.register({ username, displayName })
|
||||||
this.guilds = []
|
this.guilds = []
|
||||||
this.mode = 'home'
|
this.mode = 'home'
|
||||||
return this._bootstrapAfterUser(user)
|
const boot = await this._bootstrapAfterUser(user)
|
||||||
|
span.end({ userId: user?.id || null })
|
||||||
|
return boot
|
||||||
|
} catch (err) {
|
||||||
|
this.log.error('identity.register error', {
|
||||||
|
username: username || null,
|
||||||
|
err: err?.message || String(err)
|
||||||
|
})
|
||||||
|
span.fail(err)
|
||||||
|
throw err
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async createDevicePairCode ({ deviceLabel, ttlMs } = {}) {
|
async createDevicePairCode ({ deviceLabel, ttlMs } = {}) {
|
||||||
@@ -6350,6 +6369,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
span.end({
|
span.end({
|
||||||
|
guildId: guildRecord.id,
|
||||||
channels: channels.length,
|
channels: channels.length,
|
||||||
activeChannelId: this.activeChannelId,
|
activeChannelId: this.activeChannelId,
|
||||||
noViewableChannels: !!this._guildOpenNoViewableChannels,
|
noViewableChannels: !!this._guildOpenNoViewableChannels,
|
||||||
@@ -6373,6 +6393,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const user = this.identity.user
|
const user = this.identity.user
|
||||||
if (!user) throw new Error('register first')
|
if (!user) throw new Error('register first')
|
||||||
this._invalidateSearchCache()
|
this._invalidateSearchCache()
|
||||||
|
this._lastSearchFromCache = false
|
||||||
const hadGuilds = this.guilds.length
|
const hadGuilds = this.guilds.length
|
||||||
const listOnDiscovery = publicListing !== false
|
const listOnDiscovery = publicListing !== false
|
||||||
await this._leaveMeshes()
|
await this._leaveMeshes()
|
||||||
@@ -6519,6 +6540,7 @@ class PearcordPlatform extends EventEmitter {
|
|||||||
const id = String(guildId || '')
|
const id = String(guildId || '')
|
||||||
if (!id) throw new Error('guildId required')
|
if (!id) throw new Error('guildId required')
|
||||||
this._invalidateSearchCache()
|
this._invalidateSearchCache()
|
||||||
|
this._lastSearchFromCache = false
|
||||||
const span = this.log.time('guild.load', { guildId: id })
|
const span = this.log.time('guild.load', { guildId: id })
|
||||||
const guild = await this.db.get(COLLECTIONS.GUILDS, { id })
|
const guild = await this.db.get(COLLECTIONS.GUILDS, { id })
|
||||||
if (!guild) {
|
if (!guild) {
|
||||||
|
|||||||
Reference in New Issue
Block a user