Skip to content

Commit 1387215

Browse files
authored
Merge pull request nullstack#376 from HallexCosta/fix-conflict-invokerHash-and-boundHash-separator
Fix conflict invoker hash and bound hash separator
2 parents 7e71ae2 + 7079434 commit 1387215

File tree

3 files changed

+12
-3
lines changed

3 files changed

+12
-3
lines changed

client/invoke.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import deserialize from '../shared/deserialize'
22
import prefix from '../shared/prefix'
3+
import { symbolHashJoin } from '../shared/symbolHash'
34
import page from './page'
45
import worker from './worker'
56
import client from './client'
@@ -13,7 +14,7 @@ export default function invoke(name, hash) {
1314
} else {
1415
worker.queues[name] = [...worker.queues[name], params]
1516
}
16-
let finalHash = hash === this.hash ? hash : `${hash}-${this.hash}`
17+
let finalHash = hash === this.hash ? hash : symbolHashJoin(hash, this.hash)
1718
let url = `${worker.api}/${prefix}/${finalHash}/${name}.json`
1819
if (module.hot) {
1920
const version = client.klasses[hash].__hashes[name]

server/server.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import bodyParser from 'body-parser'
22
import express from 'express'
33
import path from 'path'
44
import deserialize from '../shared/deserialize'
5+
import { symbolHashSplit } from '../shared/symbolHash'
56
import prefix from '../shared/prefix'
67
import context, { getCurrentContext, generateCurrentContext } from './context'
78
import emulatePrerender from './emulatePrerender'
@@ -123,7 +124,7 @@ server.start = function () {
123124
const payload = request.method === 'GET' ? request.query.payload : request.body
124125
const args = deserialize(payload)
125126
const { hash, methodName } = request.params
126-
const [invokerHash, boundHash] = hash.split('-')
127+
const [invokerHash, boundHash] = symbolHashSplit(hash)
127128
const key = `${invokerHash}.${methodName}`
128129
await load(boundHash || invokerHash)
129130
const invokerKlass = registry[invokerHash]
@@ -154,7 +155,7 @@ server.start = function () {
154155
const payload = request.method === 'GET' ? request.query.payload : request.body
155156
const args = deserialize(payload)
156157
const { version, hash, methodName } = request.params
157-
const [invokerHash, boundHash] = hash.split('-')
158+
const [invokerHash, boundHash] = symbolHashSplit(hash)
158159
let [filePath, klassName] = (invokerHash || boundHash).split("___")
159160
const file = path.resolve('..', filePath.replaceAll('__', '/'))
160161
console.info('\x1b[1;37m%s\x1b[0m', ` [${request.method}] ${request.path}`)

shared/symbolHash.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export function symbolHashSplit(hash) {
2+
return hash.split('---')
3+
}
4+
5+
export function symbolHashJoin(hash, joinHash) {
6+
return `${hash}---${joinHash}`
7+
}

0 commit comments

Comments
 (0)